diff options
author | Michael I. Bushnell <mib@gnu.org> | 1994-09-30 16:04:15 +0000 |
---|---|---|
committer | Michael I. Bushnell <mib@gnu.org> | 1994-09-30 16:04:15 +0000 |
commit | abbd94e0375300e8ae705ad80e74522864ccf302 (patch) | |
tree | 405bcdc6fc062d015a1818437798e6404649ed29 | |
parent | 966e1e51ed4cb61b223f3641575a949902b907e0 (diff) |
Formerly update.c.~2~
-rw-r--r-- | sutils/update.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/sutils/update.c b/sutils/update.c index 232373ac..07e38e41 100644 --- a/sutils/update.c +++ b/sutils/update.c @@ -18,9 +18,42 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include <unistd.h> +#include <stdio.h> +#include <fcntl.h> + +int main () { - daemon (0, 0); + int fd; + + switch (fork ()) + { + case -1: + perror ("Cannot fork"); + exit (1); + case 0: + break; + default: + _exit (0); + } + + if (setsid () == -1) + { + perror ("Cannot setsid"); + exit (1); + } + chdir ("/"); + + fd = open ("/dev/null", O_RDWR, 0); + if (fd != -1) + { + dup2 (fd, STDIN_FILENO); + dup2 (fd, STDOUT_FILENO); + dup2 (fd, STDERR_FILENO); + if (fd < STDERR_FILENO) + close (fd); + } for (;;) { |