kjb_system_2 - A helper for kjb_system(), wrapper for system()
Example compile flags (system dependent):
-DLINUX_X86_64 -DLINUX_X86_64_OPTERON -DGNU_COMPILER
-lKJB -lfftw3 -lgsl -lgslcblas -ljpeg -lSVM -lstdc++ -lpthread -lSLATEC -lg2c -lacml -lacml_mv -lblas -lg2c -lncursesw
const char *command,
This function is different than kjb_system() in that 1) it dodges the process
that sits in the background to handle incomming system call requests; and 2)
it provides a simple return code for the command executed (if argument
prog_rc_ptr is not NULL). It is different than system() in that output to
stderr is collected as error messages (until the space for them is used up,
in which case they should be dropped --- we should check this still work!).
If argument prog_rc_ptr is not NULL, then *prog_rc_ptr will be set to the
shell return codes by the following table (not everything has been checked),
and, if none of these apply, then the return code of what running program
chooses to return, as you would expect.
| 1 Catchall for general errors
2 Misuse of shell builtins
126 Command invoked cannot execute
127 "command not found"
128 Invalid argument to exit
128+n Fatal error signal "n"
255 Exit status out of range
This function has historical baggage due to trying to do what seems hard to
do easily which is to separate out the notions of 1) the shell failing to get
the command(s) running with the various IO redirections; and 2) the
subsequently well formed command reports an error return code. This is not
implemented due to difficulties --- it seems that doing so in the general
case would require parsing composite commands into smaller commands, checking
that they can be executed, and checking the IO redirects. Currently, the
cases we cannot handle well are composite cases that we do not want to do
this analysis, and so we adopt the shell's version of the situation, which
means that something like:
ls < NON_EXISTANT
will have an error code of "1" which may or may not be what we want (but it
is consistant with the shell). However,
will get return code "127", and
will get return code "126".
This software is not adequatedly tested. It is recomended that
results are checked independantly where appropriate.