system($path_to_my_executable); my $exit_value = $? >> 8; my $signal_num = $? & 127; my $dumped_core = $? & 128; # check for segfaults if ($signal_num == 11) { if (!$dumped_core) { printf("ERROR: executable exited with segmentation fault.\n"); exit(-1); } else { printf("ERROR: executable exited with segmentation fault (core dumped).\n"); } } elsif ($signal_num != 0) { printf("ERROR: executable exited abnormally with signal $signal_num\n"); exit(-1); } elsif ($exit_value == 255) { printf("ERROR: executable exited abnormally with value -1, exiting...\n"); exit(-1); }