tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* Defunct daemon problem
@ 1995-05-18 23:57 Ian Nicholls
  0 siblings, 0 replies; only message in thread
From: Ian Nicholls @ 1995-05-18 23:57 UTC (permalink / raw)
  To: tru64-unix-managers

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          >>

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-05-18 23:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-05-18 23:57 Defunct daemon problem Ian Nicholls

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox