Skip to content

Commit

Permalink
Kill the zeusclient only if something went wrong
Browse files Browse the repository at this point in the history
Previously, the runner would kill the client process at_exit - this
introduced a race condition where the client would sometimes get the
async TERM signal before it could read the exit status, and exit with
a failure status.

While the reasoning behind killing the client is sound (if the runner
dies without the client noticing, the client could hang around
forever), it should only happen if there's an exceptional condition.
  • Loading branch information
antifuchs committed Mar 3, 2013
1 parent fed0652 commit 29003f2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rubygem/lib/zeus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,17 @@ def command(identifier, sock)

kill_command_if_client_quits!(pid, client_pid)

at_exit{ Process.kill(:TERM, client_pid) }

Process.wait(pid)
code = $?.exitstatus || 0

local.write "#{code}\0"

local.close
rescue Exception
# If anything at all went wrong, kill the client - if anything
# went wrong before the runner can clean up, it might hang
# around forever.
Process.kill(:TERM, client_pid)
end

def kill_command_if_client_quits!(command_pid, client_pid)
Expand Down

0 comments on commit 29003f2

Please sign in to comment.