lib/rbbt/util/cmd.rb in rbbt-util-3.0.3 vs lib/rbbt/util/cmd.rb in rbbt-util-3.1.0
- old
+ new
@@ -27,21 +27,33 @@
@post.call if @post
original_close
end
+ def force_close
+ if @pid
+ Log.debug "Forcing close by killing '#{@pid}'"
+ Process.kill("KILL", @pid)
+ Process.waitpid(@pid)
+ end
+ @post.call if @post
+ original_close
+ end
+
alias original_read read
def read
data = Misc.fixutf8(original_read)
self.close unless self.closed?
data
end
+
}
io
end
- end
+ end
+
def self.process_cmd_options(options = {})
string = ""
options.each do |option, value|
case
when value.nil? || FalseClass === value
@@ -107,10 +119,9 @@
STDOUT.sync = STDERR.sync = true
exec(cmd)
rescue Exception
raise CMDError, $!.message
end
-
}
sin.first.close
sout.last.close
serr.last.close