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

Thanks everyone for the assistance/suggestions. This isn't a major issue for me or anything. I just happened to notice this when I added a system() to an existing program that already ignored sigCHLD. I have a workaround -- in fact, I think the reason that sigCHLD was ignored was that there used to be a fork() call, but now that's gone. I'm no longer ignoring the signal, so it's not a problem for now.

I just recompiled a new version of 5.8.1 on my linux box and it still exhibits the same behavior. Oh, and I changed the parameter to system() to be './prog2.pl' with the same results. It looks like this account has a 'dot' in the $PATH. (bad, I know)

Here are the versions that I have tested:

linux 2.4.20-20.9 kernel (from RedHat9)
tested with both perl v5.8.0 and v5.8.1
using glibc 2.3.2 (glibc-2.3.2-27.9)

sun 5.8 Generic_108528-17 sun4u sparc SUNW, UltraSPARC-IIi-cEngine
perl v5.6.1
not sure how to tell the C library version on sun

FreeBSD 4.8-RELEASE
perl version 5.005_03
not sure how to tell the C library on FreeBSD

If you guys think I should submit a bug report, I'll definitely do that.

I haven't tested it, but I assume another workaround if someone really needed it would be to do the waitpid() inside of a reaper subroutine construct.

  • Comment on Re: Re: why does ignoring sigCHLD corrupt return value from system()?

Replies are listed 'Best First'.
Re: Re: Re: why does ignoring sigCHLD corrupt return value from system()?
by ant9000 (Monk) on Nov 05, 2003 at 11:12 UTC
    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
      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
Re: why does ignoring sigCHLD corrupt return value from system()?
by Abigail-II (Bishop) on Nov 05, 2003 at 10:37 UTC
    Yes, please do submit a bug report, using perlbug. Perlbug will include the output of 'perl -V', and among this output is the C library version number. Without a bug report, the issue is unlikely to get fixed, unless you send in a patch yourself.

    I'm not able to reproduce this problem using Linux, kernel 2.4.18-something (for various somethings), glibc 2.2.5, and Perl versions 5.005 .. 5.9.0.

    Abigail