in reply to Re: Re: why does ignoring sigCHLD corrupt return value from system()?
in thread why does ignoring sigCHLD corrupt return value from system()?

The following piece of code examines the problem a bit further, along the guidelines of perlport:
#!/usr/bin/perl use POSIX; if(@ARGV){ $SIG{'CHLD'} = 'IGNORE'; } system('./prog2.pl'); $status=$?; if(WIFEXITED($status)){ print "prog2.pl exited normally, returning ", WEXITSTATUS($status), "\n"; }elsif(WIFSIGNALED($status)){ print "prog2.pl was terminated with signal ", WTERMSIG($status), "\n"; }elsif(WIFSTOPPED($status)){ print "prog2.pl is stopped for signal ", WSTOPSIG($status), "\n"; }else{ print "can't understand what happened to prog2.pl; ", "status is ",$status,"\n"; }

When I ran it under perl 5.8.0 (on i386 linux, kernel 2.4.20, glibc 2.3.2), I got the following results:
#./prog1.pl
prog2.pl exited normally, returning 5
#./prog1.pl ignore
prog2.pl was terminated with signal 127
Interesting enough, no POSIX signal has number 127, AFAIK... something is not working here.
Ant9000
  • Comment on Re: Re: Re: why does ignoring sigCHLD corrupt return value from system()?
  • Download Code

Replies are listed 'Best First'.
Re: why does ignoring sigCHLD corrupt return value from system()?
by fiberhalo (Acolyte) on Nov 05, 2003 at 16:08 UTC
    Thanks for the code there. I used it in my bug submission report (bug #24423); I hope that's okay.

    Again, thanks to everyone for all the help.

      'f course it's okay!
      That's exactly what Open Source is about :-) Ant9000