in reply to How to capture system return code when command launched in the background?

The execution of the program (java) in the background is actually successful. It's just that later on java decides to exit with a non-successful return value.

In general you have to wait for the external program to terminate to obtain its exit code. I'm not sure if waitpid or wait support obtaining the return value; if not you have to fork yourself, and start the program in foreground, and collect the return value, and then use some IPC to signal that back to the parent process. Sounds nasty...

Luckily IPC::Run abstracts that away with start() and finish() - which I'd recommend to use.

  • Comment on Re: How to capture system return code when command launched in the background?