jobd.pl: never return from exec_job_command in the child
commitc73185f064baaf8ecab1aebb06233ebd6bd4e424
authorKyle J. McKay <mackyle@gmail.com>
Mon, 4 Jul 2016 09:07:52 +0000 (4 02:07 -0700)
committerKyle J. McKay <mackyle@gmail.com>
Mon, 4 Jul 2016 09:07:52 +0000 (4 02:07 -0700)
treed8e70a5d030dae87ae9e067b0c22dc22e6e409af
parented355914a0b39573889b73bcd3df8ceb8e71433a
jobd.pl: never return from exec_job_command in the child

If exec_job_command returns when it's running in the child
of the fork, then essentially two copies of jobd.pl will start
running at that point leading to all kinds of havoc.

This could only happen if the redirect of stdin/stdout to /dev/null
failed or the setpgid call failed.

Normally none of these ever fail.  However, under unusual circumstances
the setpgid call may fail temporarily.  If this happens, the child
MUST NOT return as that will essentially create multiple jobd.pl
processes.  Instead the child MUST always exit with an error code
if a problem occurs before the child's process is replaced with the
'exec' process.

Also make sure the child exits with a non-zero value, that such an
exit triggers 'on_error' instead of 'on_success' and improve the
race condition issue by setting finished to 0 before the fork and
moving the "prevent races" delay to before any possible error exits.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
jobd/jobd.pl