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
12 * 'But the night will be too short,' said Gandalf. 'I have come back here,
13 * for I must have a little peace, alone. You should sleep, in a bed while you
14 * still may. At the sunrise I shall take you to the Lord Denethor again. No,
15 * when the summons comes, not at sunrise. The Darkness has begun. There will
22 #include <sys/types.h>
33 main(int argc
, char *argv
[])
39 fprintf(stderr
, "Usage: blindtty CMD [ARG]...\n");
43 pid
= forkpty(&ptm
, NULL
, NULL
, NULL
);
45 int i
; for (i
=0; i
<argc
; i
++) argv
[i
] = argv
[i
+1]; argv
[i
]=NULL
;
46 execvp(argv
[0], argv
);
47 perror("execvp() failed");
51 printf("%s started with pid %d\n", argv
[1], pid
);
53 signal(SIGCHLD
, sigchld
);
57 if (read(ptm
, buf
, 1024) <= 0)