The value returned by system/$? is from the OS. If the OS says the child segfaulted, there's not much Perl can do but to trust it.
I find it very unlikely that the OS would say it segfaulted if it didn't.
Update: Not on Windows, I suppose. Windows has larger exit codes that are squished into the unix format. Are you on Windows? Maybe there's a bug in the emulation.
| [reply] [d/l] [select] |
My os is solaris 10.
Stating the problem again.
I am invoking the script x.pl from y.pl as system(x.pl); my $exit_status = $? >> 8; I am capturing the status always. It sometimes happen that x.pl is able to execute successfuly (it updates a database before exiting). But capturing the error status in y.pl shows the system(x.pl) has a exit status of segmentation fault.
| [reply] |
You can't find out if a segfault occured by looking at $? >> 8. Do you mean $? & 127? What's the value of $??
In any case, if a segfault did occur, I can't see how Perl was responsible.
| [reply] [d/l] [select] |
How do you call y.pl when you capture the error, as opposed to when not capturing the error?
--
Ronald Fischer <ynnor@mm.st>
| [reply] [d/l] |
I am invoking the script x.pl from y.pl
as
system(x.pl);
my $exit_status = $? >> 8;
I am capturing the status always.
It sometimes happen that x.pl is able to execute successfuly (it updates a database before exiting). But capturing the error status in y.pl shows the system(x.pl) has a exit status of segmentation fault.
My os is solaris 10
| [reply] |
I am invoking the script x.pl from y.pl as system(x.pl);
I take it to mean system('x.pl');. And I guess you made sure that x.pl has a correct #! line?
my $exit_status = $? >> 8; I am capturing the status always.
How do you know that your program died by segmentation fault? $? >> 8 is whatever x.pl passes to its exit call, so from this value alone, you can not deduce that your program segfaulted.
But *if* it does, it could be that either the Perl used has a problem (that's why I'm asking you about the #! line), or (more likely) that x.pl uses some Perl module which contains compiled parts, so this would be the place to look.
--
Ronald Fischer <ynnor@mm.st>
| [reply] [d/l] [select] |