mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-13 12:35:54 +00:00
23 lines
494 B
C++
23 lines
494 B
C++
#include <errno.h>
|
|
#include <fcntl.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
int main (int argc, char** argv) {
|
|
char *slave_path = ttyname(STDIN_FILENO);
|
|
// open implicit attaches a process to a terminal device if:
|
|
// - process has no controlling terminal yet
|
|
// - O_NOCTTY is not set
|
|
close(open(slave_path, O_RDWR));
|
|
|
|
char *cwd = argv[1];
|
|
char *file = argv[2];
|
|
argv = &argv[2];
|
|
|
|
if (strlen(cwd) && chdir(cwd) == -1) {
|
|
_exit(1);
|
|
}
|
|
|
|
execvp(file, argv);
|
|
return 1;
|
|
}
|