2 * blindtty - run command in a detached terminal
4 * Usage: blindtty CMD [ARGS]...
6 * You might find it useful to run it as "setsid blindtty CMD...".
8 * Copyright (c) 2006 Petr Baudis, Jan Sembera
14 #include <sys/types.h>
25 main(int argc
, char *argv
[])
31 fprintf(stderr
, "Usage: blindtty CMD [ARG]...\n");
35 pid
= forkpty(&ptm
, NULL
, NULL
, NULL
);
37 int i
; for (i
=0; i
<argc
; i
++) argv
[i
] = argv
[i
+1]; argv
[i
]=NULL
;
38 execvp(argv
[0], argv
);
39 perror("execvp() failed");
43 printf("%s started with pid %d\n", argv
[1], pid
);
45 signal(SIGCHLD
, sigchld
);
49 if (read(ptm
, buf
, 1024) <= 0)