in reply to system return -1

The documentation not only explains what it means using prose — "Return value of -1 indicates a failure to start the program or an error of the wait(2) system call (inspect $! for the reason)." — it also provides sample code.
if ($rv == -1) { print "failed to execute: $!\n"; } ...

(The code example actually checks $?, which will have the same value as what system returns.)

Replies are listed 'Best First'.
Re^2: system return -1
by Anonymous Monk on Oct 25, 2010 at 10:53 UTC
    I had read the documentation before posing the question.
    As far as Perl is concerned it is failing with "no child processes". This implies that the called script via the system fork is not exiting cleanly. This is not the case however becuase as demonstrated in the code I put forward the shell script is exiting with a 0 and it also contains an exit 0 in the script.
    I'm not sure how to overcome this problem becuase the documentation says
    an implicit fork (2) is done with system , backquotes, or opening a pr +ocess as a filehandle. Be very careful to end the child code with an +exit
    How do I stop it from producing a "no child process" error ?
      $! is "no child processes"? That would indicate you are reaping the children elsewhere. (It doesn't have anything to do with exiting cleanly or not.) Are you using $SIG{CHLD}='IGNORE';, wait or waitpid anywhere?