From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96075319906617.tru64-unix-managers.marc@archive.invalid> From: "Ian Nicholls" Date: Thu, 18 May 1995 23:57:35 +0000 To: tru64-unix-managers Subject: Defunct daemon problem X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96075319906617 To anyone who may be able to help The following 'C' program creates a daemon process which in turn forks off another child process. The problem we are experiencing is that under OSF/1 version 3.22 Unix when the last child exits, its process remains as a . This problem does not occur under AT&T SVR4 Unix. We have even tried to ignore all other signals but the defunct problem on OSF/1 Unix still remains. :-( If anyone has any ideas as how to overcome this problem your feedback will be highly appreciated. :-) ================================================================================ #include #include #include #include void AbortProg(int value); main() { int pid; daemon(); pid = fork(); switch(pid) { case -1: exit(1); break; case 0: setpgrp(); exit(0); default: for(;;); } } static daemon() { int fd; if (fork() != 0) exit(0); /* Parent exits */ setpgrp(); signal(SIGHUP,SIG_IGN); if (fork() != 0) exit(0); for(fd=0; fd != NOFILE; fd++) close(fd); errno = 0; umask(0); signal(SIGHUP,AbortProg); signal(SIGINT,AbortProg); signal(SIGQUIT,AbortProg); signal(SIGILL,AbortProg); signal(SIGTRAP,AbortProg); signal(SIGIOT,AbortProg); signal(SIGEMT,AbortProg); signal(SIGFPE,AbortProg); signal(SIGCHLD,SIG_IGN); signal(SIGCLD,SIG_IGN); } void AbortProg(int value) { exit(0); } -------------------------------------------------------------------------------- -- << E-mail: inicholl@coles.com.au Phone: +61 3 9829 6088, Fax: +61 3 9829 6886 >> << Post: Coles Supermarkets, PO Box 480, Glen Iris 3146, Australia >>