I am trying to catch the exit code of a shell script executed by my script. I used a friends code to 'daemonize' and then mask for signals with the 'POSIX' module.
The problem that I now have is once the following piece of code is run '$?' is always '-1' regardless of the exit from the last command run in (``)'s.
I have read that once a new sigchld is installed the $? cannot be trusted.
My question, is there any way to retain the '$?' or like behavior after messing with sigchld?
# START_SUB
sub setSigDisposition() {
my ($sighandler,$snum);
#
# The set of signals to mask
#
my $sigset = POSIX::SigSet->new;
$sigset->fillset();
#
# Don't mask these signals because wouldn't want to continue
# if one these sent, even in critical section(s).
#
$sigset->delset( &POSIX::SIGILL );
$sigset->delset( &POSIX::SIGSEGV );
$sigset->delset( &POSIX::SIGFPE );
$sigset->delset( &POSIX::SIGINT );
foreach $snum( split(' ', $Config{sig_num}) ){
$SIG{CHLD} = 'IGNORE';
if( $snum == &POSIX::SIGILL || $snum == &POSIX::SIGSEGV || $snum =
+= &POSIX::SIGFPE || $snum == &POSIX::SIGINT ){
$sighandler = "main::death";
}
# elsif( $snum == &POSIX::SIGTERM ){
# $sighandler = "main::shutdown";
# }
else{
$sighandler = "main::reaper";
}
# Set signal disposition ...
POSIX::sigaction(
$snum,
POSIX::SigAction->new( $sighandler,
POSIX::SigSet->new,
&POSIX::SA_NOCLDSTOP ),
POSIX::SigAction->new( $sighandler,
POSIX::SigSet->new,
&POSIX::SA_NOCLDSTOP )
);
}
return $sigset;
}
# END_SUB
Thanks!
-Bryan
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.