Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Perl: porters

problem with signal handling

 

 

Perl porters RSS feed   Index | Next | Previous | View Threaded


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'


okamoto at hpcc123

Sep 25, 1995, 9:50 PM

Post #2 of 4 (140 views)
Permalink
Re: problem with signal handling [In reply to]

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

No, this is "standard" behaviour for various versions of Unix. I'll bet you'd
see the same thing in a C program. You might check to see if you have the
POSIX extension and use the signal handlers in that extension.

Good luck,

Jeff


tye at metronet

Sep 25, 1995, 10:52 PM

Post #3 of 4 (140 views)
Permalink
Re: problem with signal handling [In reply to]

Excerpts from the mail message of Dan Cantrell:
) [...] 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().

As already noted in c.l.p.m, this is standard System V broken
signal handling. The only "Perl bug" is that Perl doesn't
choose POSIX signal handling over SysV.

--
Tye McQueen tye [at] metronet || tye [at] doober
Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


lwall at scalpel

Sep 26, 1995, 10:25 AM

Post #4 of 4 (144 views)
Permalink
Re: problem with signal handling [In reply to]

: Excerpts from the mail message of Dan Cantrell:
: ) [...] 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().
:
: As already noted in c.l.p.m, this is standard System V broken
: signal handling. The only "Perl bug" is that Perl doesn't
: choose POSIX signal handling over SysV.

It's been in the wishlist for a long time. If anyone wanted to work up
a patch, I'd certainly consider putting it in for 5.002. I'm not sure
if any Configure support would be needed, though.

Larry

Perl porters RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.