I am debugging an issue with a compiled program written in c++ that is being called from a perl script. If I create a shell script that calls the compiled program directly:
#!/bin/tcsh myexecutable exit
And then run it, the last 2 lines written to the console are:
right before out-of-bounds array access Segmentation fault
If I instead write the following standalone perl script:
#!/tool/bin/perl use strict; my $cmd = "myexecutable"; system($cmd); my $exit_value = $? >> 8; my $signal_num = $? & 127; my $dumped_core = $? & 128; printf("exit_value = $exit_value, signal_num = $signal_num, dumped_cor +e = $dumped_core\n");
The last line printed from the executable is:
right before out-of-bounds array access
The values of the variables are as follows: exit_value = 0, signal_num = 11, dumped_core = 0 Why in this case is the "Segmentation fault" text not captured by the perl script? The behavior is the same if I replace this line:
with this:system($cmd);
my $backtick_return = `$cmd`;
and then print $backtick_return at the end of the program. When I first started debugging this issue I was unaware of how to properly check system() return codes. Now that I've added that check as shown above debugging future issues should be easier, but I would still like to know why the "Segmentation fault" text isn't being captured by the system command, as seeing that when I first started debugging this issue would have been helpful.
In reply to "Segmentation fault" text not captured by perl script by Special_K
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |