The program executed under system
may return a specific code when it exits. That is packaged into high bits of a number (exit status) which Perl gets and which is available in $?
. This is why you want to test that number, for example (but see below)
system($cmd) == 0 or die "Error: $?";
Or, you can separately check $? after the call. If true (non-zero), that only means that there was something other than a clean exit by the application, or a problem with system
itself. When you unpack that you are looking for what the application communicated on its exit. In order to merely see whether there was an error you only look at $?
, and you are getting a value. So there is no conflict.
What code that program returned is its business (design decision). Programs ideally exit with codes when they fail (if they can detect and handle the problem), and have documentation explaining what code means what. For an example see this answer, and for another comment this one.
As seen in system, you readily get: exit code $? >> 8
, signal number $? & 127
, and whether core was dumped $? & 128
. With your exit status of 134
the signal number is 6
, which man 7 signal
lists as SIGABRT
. The core should be there as well. So that is what you got from your program, and no explicit exit code. Apparently, the program caused abort and dumped core.
In your case, you know where all this comes from -- assert
is a macro which calls abort
, whereby SIGABRT
is raised (man 3 assert abort
). Perl gets back that 6
packaged into 134
.
Note that assert
prints a message to STDERR
, so you may want to run the program via qx
(backticks), in which case you can capture that error. See the first link above, or search on SO.