Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Zombies are haunting me! HELP!
@ 1998-05-26  4:00 William Clark
  1998-05-27  4:00 ` Steve VanDevender
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: William Clark @ 1998-05-26  4:00 UTC (permalink / raw)



Hello there,

I am writing c code on a DEC Alpha box running DEC Unix.

I have created a daemon that forks a child to receive a file
from a remote process.

Everything works great EXCEPT that I am collecting a zombie
for each terminated child process.

I am using the signal function with SIGCHLD,SIG_IGN params before
I start the loop that waits for a sockets connection and forks
the child.

I thought that would prevent zombies.

Any ideas would be appreciated. Thanks in advance.

billc




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Zombies are haunting me! HELP!
  1998-05-26  4:00 Zombies are haunting me! HELP! William Clark
@ 1998-05-27  4:00 ` Steve VanDevender
  1998-05-28  4:00   ` Serguei Patchkovskii
  1998-05-27  4:00 ` news.encomix.es
  1998-05-28  4:00 ` Jeff Denham
  2 siblings, 1 reply; 5+ messages in thread
From: Steve VanDevender @ 1998-05-27  4:00 UTC (permalink / raw)



clark@knowideas.com (William Clark) writes:

> Hello there,
> 
> I am writing c code on a DEC Alpha box running DEC Unix.
> 
> I have created a daemon that forks a child to receive a file
> from a remote process.
> 
> Everything works great EXCEPT that I am collecting a zombie
> for each terminated child process.
> 
> I am using the signal function with SIGCHLD,SIG_IGN params before
> I start the loop that waits for a sockets connection and forks
> the child.
> 
> I thought that would prevent zombies.
> 
> Any ideas would be appreciated. Thanks in advance.
> 
> billc

Quite simply, the parent must issue a wait() system call for each
child that it forks.  A child will remain in a zombie state until
the parent collects its exit status with wait() (or wait3() or
wait4(); see "man 2 wait" for additional information).  Ignoring
SIGCHLD will not prevent zombies; in fact, it will be more likely
to preserve them.  Normally you would want to catch SIGCHLD and
issue a wait() from in the signal handler if you want to be able
to handle child exits asynchronously.

-- 
Steve VanDevender  "I ride the big iron"  http://jcomm.uoregon.edu/~stevev
stevev@hexadecimal.uoregon.edu  PGP keyprint 4AD7AF61F0B9DE87 522902969C0A7EE8
"bash awk grep perl sed df du, du-du du-du,
vi troff su fsck rm * halt LART LART LART!" -- the Swedish BOFH



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Zombies are haunting me! HELP!
  1998-05-26  4:00 Zombies are haunting me! HELP! William Clark
  1998-05-27  4:00 ` Steve VanDevender
@ 1998-05-27  4:00 ` news.encomix.es
  1998-05-28  4:00 ` Jeff Denham
  2 siblings, 0 replies; 5+ messages in thread
From: news.encomix.es @ 1998-05-27  4:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 730 bytes --]



William Clark escribi� en mensaje <6ken58$9e0@examiner.concentric.net>...
>Hello there,
>
>I am writing c code on a DEC Alpha box running DEC Unix.
>
>I have created a daemon that forks a child to receive a file
>from a remote process.
>
>Everything works great EXCEPT that I am collecting a zombie
>for each terminated child process.
>
>I am using the signal function with SIGCHLD,SIG_IGN params before
>I start the loop that waits for a sockets connection and forks
>the child.
>
>I thought that would prevent zombies.
>
the best way to prevent zombies is that the father catch the SIGCHLD and in
that funtion you call wait(). That will kill your zombies.

>Any ideas would be appreciated. Thanks in advance.
>
>billc
>





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Zombies are haunting me! HELP!
  1998-05-26  4:00 Zombies are haunting me! HELP! William Clark
  1998-05-27  4:00 ` Steve VanDevender
  1998-05-27  4:00 ` news.encomix.es
@ 1998-05-28  4:00 ` Jeff Denham
  2 siblings, 0 replies; 5+ messages in thread
From: Jeff Denham @ 1998-05-28  4:00 UTC (permalink / raw)



William Clark wrote:

> Hello there,
>
> I am writing c code on a DEC Alpha box running DEC Unix.
>
> I have created a daemon that forks a child to receive a file
> from a remote process.
>
> Everything works great EXCEPT that I am collecting a zombie
> for each terminated child process.
>
> I am using the signal function with SIGCHLD,SIG_IGN params before
> I start the loop that waits for a sockets connection and forks
> the child.
>
> I thought that would prevent zombies.
>
> Any ideas would be appreciated. Thanks in advance.
>
> billc

 You're expecting System V semantics, and you don't get that by
default
for the signal() function on Digital UNIX. If you build in the UNIX 95

environment (using c89 instead of cc) or add -lsys5 to your link
command,
you'll get the behavior you're expecting.

However, the best way to do this is to switch to the POSIX sigaction
routine
using an sa_flags value of SA_NOCLDWAIT in your call for SIGCHLD.
This eliminates the need to call wait() as well. See the sigaction man
page.

Jeff
__________________________________________________
Jeff Denham (jdenham@brighttiger.com)

Bright Tiger Technologies
SmartCluster� Software for Distributed Web Servers
http://www.brighttiger.com

125 Nagog Park
Acton, MA 01720
Phone: (978) 263-5455 x177
Fax:   (978) 263-5547





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Zombies are haunting me! HELP!
  1998-05-27  4:00 ` Steve VanDevender
@ 1998-05-28  4:00   ` Serguei Patchkovskii
  0 siblings, 0 replies; 5+ messages in thread
From: Serguei Patchkovskii @ 1998-05-28  4:00 UTC (permalink / raw)



Steve VanDevender (stevev@hexadecimal.uoregon.edu) wrote:

: Quite simply, the parent must issue a wait() system call for each
: child that it forks.  A child will remain in a zombie state until

Quite simply, this assertion is wrong if taken literally. If the 
parent process is not interested in the child's exit codes, it
is possible to arrange for dead children to be disposed of without
parent's interverntion. The sigaction(2) manual page provides all
the gory details, but in practice doing:

	struct	sigaction  action ;

action.sa_handler = SIG_IGN ;
action.sa_mask    = 0 ;
action.sa_flags   = SA_NOCLDSTOP|SA_NOCLDWAIT ;
sigaction( SIGCHLD, &action, NULL ) ;

will make waiting for your childs not necessary. (It is still
possible to synchronize with the children processes, see wait(2)
and sigaction(2) manual pages). On some other unices (e.g. AIX), 
simply setting SIGCHLD to SIG_IGN by doing signal(SIGCHLD,SIG_IGN) 
will have the same effect. On Digital Unix, the same behaviour 
can be obtained by linking with system V compatibility library 
(-lsys5), even though I cannot find any references to this in 
the manual pages. Linking either with bsd signals library, or 
with the default libc handler will result in zombies.

As usual, there is more than one way to skin a cat.

/Serge.P




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1998-05-28  4:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-05-26  4:00 Zombies are haunting me! HELP! William Clark
1998-05-27  4:00 ` Steve VanDevender
1998-05-28  4:00   ` Serguei Patchkovskii
1998-05-27  4:00 ` news.encomix.es
1998-05-28  4:00 ` Jeff Denham

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