Skip to content

Commit

Permalink
Push exit status even when stdin/stdout/stderr closing freaks out.
Browse files Browse the repository at this point in the history
  • Loading branch information
Graham Hughes committed Mar 3, 2011
1 parent cdb8a9d commit ddd6688
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/linux/right_popen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,16 @@ def self.popen3_imp(options)
wait_timer = EM::PeriodicTimer.new(1) do
value = Process.waitpid2(pid, Process::WNOHANG)
unless value.nil?
ignored, status = value
wait_timer.cancel
stdin.close_connection
stdout.close_connection
stderr.close_connection
options[:target].method(options[:exit_handler]).call(status) if
options[:exit_handler]
begin
ignored, status = value
options[:target].method(options[:exit_handler]).call(status) if
options[:exit_handler]
ensure
stdin.close_connection
stdout.close_connection
stderr.close_connection
wait_timer.cancel
end
end
end
end
Expand Down

0 comments on commit ddd6688

Please sign in to comment.