From: "Ian Nicholls" <inicholl () cnw06 ! coles ! com ! au>
To: tru64-unix-managers
Subject: Defunct daemon problem
Date: Thu, 18 May 1995 23:57:35 +0000 [thread overview]
Message-ID: <96075319906617.tru64-unix-managers.marc@archive.invalid> (raw)
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@coles.com.au Phone: +61 3 9829 6088, Fax: +61 3 9829 6886 >>
<< Post: Coles Supermarkets, PO Box 480, Glen Iris 3146, Australia >>
reply other threads:[~1995-05-18 23:57 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox