in reply to Re: multi-command sytem call
in thread multi-command sytem call
When you run a process in the background via the shell (with the &), the return value is always zero.
Not so!
system, exec, and fork can all fail and depending on the function, return a non-zero value if the system cannot fork at the time (say, if there is a runaway process running that has forked too many times). Or actually, on failure fork returns undef, exec returns false, and system returns whatever the secondary process returned. Normal programs return 0 on success but are expected to return non-zero values on failure. So system is perfectly capable of returning non-zero values. When that happens, something wrong has happened in the program that system was running.
The return code of the program is in $? >> 8 so check that when it fails.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: multi-command sytem call
by etcshadow (Priest) on Aug 25, 2004 at 07:26 UTC |