Skip to content

Commit

Permalink
Merge pull request #13 from runemadsen/master
Browse files Browse the repository at this point in the history
Fixing input/output error
  • Loading branch information
pitluga committed Jan 24, 2013
2 parents 20dd6b0 + 164c27a commit 6f3140b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/subcontractor/cli.rb
@@ -1,6 +1,22 @@
require 'optparse'
require 'pty'

module SafePty
def self.spawn command, &block

PTY.spawn(command) do |r,w,p|
begin
yield r,w,p
rescue Errno::EIO
ensure
Process.wait p
end
end

$?.exitstatus
end
end

module Subcontractor
class CLI

Expand All @@ -9,7 +25,7 @@ def run
command = build_command(ARGV.dup, options)
Dir.chdir(options[:chdir]) if options[:chdir]
signal = options[:signal] || "TERM"
PTY.spawn(command) do |stdin, stdout, pid|
SafePty.spawn(command) do |stdin, stdout, pid|
trap("TERM") do
send_kill(signal, find_pids_to_kill(pid))
end
Expand Down

0 comments on commit 6f3140b

Please sign in to comment.