
dan.cantrell at xilinx
Sep 25, 1995, 8:44 PM
Post #1 of 4
(141 views)
Permalink
|
|
problem with signal handling
|
|
Brief: Not processing SIGCHLD correctly. Description: I have a program that will start child processes to do stuff and exit. One or more of these child processes may be running at a time. I want to do some things when a child exits. The first child to exit is handled fine. But, the second and all later child signals are not handled. I can reproduce this error with the included short script. I am also including the output and config info for my environment. I can get around this problem by reseting the $SIG{'CHLD'} right after the wait(). Please let me know if this is a Perl5.001m bug, or if this is particular to my build. Thank you. Dan Cantrell dan.cantrell [at] xilinx Script used to reproduce error: ------------------- #! /opt/perl5/bin/perl sub mkchld { local( $pid ); $pid = fork(); if( $pid ) { print "New: $pid\n"; push( @procs, $pid ); return; } sleep 5; exit; } $SIG{'CHLD'} = 'reap'; sub reap { local( $pid ) = wait; print "Got: $pid\n"; return; } &mkchld; sleep 10; &mkchld; sleep 10; &mkchld; sleep 10; exit; ------------------ Output from script: ----------------- New: 17033 Got: 17033 New: 17035 New: 17039 The output should have a 'Got' line for each 'New' line. Process list on machine right before program exited: ------------------- dan 17035 17032 2 0:00 <defunct> dan 17039 17032 3 0:00 <defunct> I have Perl5.001m, output of a -v: ------------------- This is perl, version 5.001 Unofficial patchlevel 1m. Copyright 1987-1994, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5.0 source kit. output of myconfig: ------------------- Summary of my perl5 (patchlevel 1) configuration: Platform: osname=solaris, osver=2.4, archname=sun4-solaris uname='sunos cray 5.4 generic_101945-10 sun4m sparc ' hint=recommended Compiler: cc='cc', optimize='-O', ld='cc' cppflags='-s' ccflags ='-s' ldflags ='' stdchar='unsigned char', d_stdstdio=define, usevfork=false voidflags=15, castflags=0, d_casti32=define, d_castneg=define intsize=4, alignbytes=8, usemymalloc=y, randbits=15 Libraries: so=so libpth=/lib /usr/lib /usr/ccs/lib /usr/local/lib libs=-lsocket -lnsl -ldl -lm -lc -lcrypt libc= Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef cccdlflags='-Kpic', ccdlflags=' ', lddlflags='-G'
|