|
|
1.1 ! root 1: #include <sys/types.h> ! 2: #include <stdio.h> ! 3: #include <ipc.h> ! 4: #include <libc.h> ! 5: #include "defs.h" ! 6: ! 7: /* detach from the terminal */ ! 8: detach(mtpt) ! 9: char *mtpt; ! 10: { ! 11: int i; ! 12: ! 13: /* equivalent to sh's & */ ! 14: switch(fork()) { ! 15: case 0: ! 16: case -1: ! 17: break; ! 18: default: ! 19: exit(0); ! 20: } ! 21: openlog(mtpt); ! 22: ! 23: /* disassociate from ttys and other process groups */ ! 24: setpgrp(getpid(), getpid()); ! 25: close(0); ! 26: close(1); ! 27: for (i=4; i<NSYSFILE; i++) ! 28: close(i); ! 29: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.