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 <defunct>. 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 <stdio.h>
#include <signal.h>
#include <errno.h>
#include <sys/param.h>
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_at_coles.com.au Phone: +61 3 9829 6088, Fax: +61 3 9829 6886 >>
<< Post: Coles Supermarkets, PO Box 480, Glen Iris 3146, Australia >>
Received on Thu May 18 1995 - 20:36:16 NZST