diff options
| author | Klaatu Sverige <[email protected]> | 2015-08-05 21:31:21 +0000 |
|---|---|---|
| committer | Klaatu Sverige <[email protected]> | 2015-08-05 21:31:21 +0000 |
| commit | 86f0721bd904d8163c5f8f2472b78169146cc67d (patch) | |
| tree | cf9e61bd495c73ece45b96242e6f575af228d01d /riemann.fmi.uni-sofia.bg/ngetty/ngetty-1.1/test-helper.c | |
| parent | 75a501d32dff3c1c1ee9a2a3dc6d5b704cc7c6d1 (diff) | |
added website data, because it had heaps of good tutorials and info
Diffstat (limited to 'riemann.fmi.uni-sofia.bg/ngetty/ngetty-1.1/test-helper.c')
| -rw-r--r-- | riemann.fmi.uni-sofia.bg/ngetty/ngetty-1.1/test-helper.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/riemann.fmi.uni-sofia.bg/ngetty/ngetty-1.1/test-helper.c b/riemann.fmi.uni-sofia.bg/ngetty/ngetty-1.1/test-helper.c new file mode 100644 index 0000000..326612d --- /dev/null +++ b/riemann.fmi.uni-sofia.bg/ngetty/ngetty-1.1/test-helper.c @@ -0,0 +1,37 @@ +#include <unistd.h> +#include <fcntl.h> +#include <time.h> +#include <sys/ioctl.h> +/* + A) $0 ./ngetty-helper /dev/ttyX [login] + B) $0 "-H" /dev/ttyX + C) $0 "-O" /dev/ttyX +*/ + +int main(int argc , char **argv, char **env) { + int k; + char *x; + if (argc<3) _exit(100); + ioctl(0, TIOCNOTTY, 0); + for (k=0; k<6; k++) close(k); + if (0 != open(argv[2], O_RDWR | O_NOCTTY)) _exit(111); + + x = argv[1]; + if (x[0] != '-') { + argv++; + execve(*argv, argv, env); + _exit(127); + } + + ++x; + switch (*x) { + case 'O': + if (fork()) _exit(0); + case 'H': + setsid(); + ioctl(0, TIOCSCTTY, 0); + sleep(15); + vhangup(); + } + _exit(0); +} |
