aws-flow-ruby
aws-flow-ruby copied to clipboard
Possible race condition in child process cleanup logic
If the SIGINT trap here happens to start between these two lines, the workers array possibly contains process IDs belonging to already stopped processes. This results in an Errno::ESRCH exception.
So we're right here:
dead_guys = Process.waitall
and then the main process receives an INT signal, delegating that to the child processes:
Signal.trap("INT") { workers.each { |w| Process.kill("INT", w) } }
but the dead PIDs are removed after the very first line:
dead_guys.each { |pid, status| workers.delete(pid); puts pid.to_s + " exited" }
Proposing fix in #120