lib/rexec/task.rb in rexec-1.4.0 vs lib/rexec/task.rb in rexec-1.4.1

- old
+ new

@@ -285,16 +285,21 @@ end if command.respond_to? :call command.call elsif Array === command + command = command.dup + # If command is a Pathname, we need to convert it to an absolute path if possible, # otherwise if it is relative it might cause problems. if command[0].respond_to? :realpath command[0] = command[0].realpath end + # exec expects an array of Strings: + command.collect! { |item| item.to_s } + exec *command else if command.respond_to? :realpath command = command.realpath end @@ -308,20 +313,28 @@ task = Task.new(cin[WR], cout[RD], cerr[RD], cid) if block_given? begin yield task + + # Close all input pipes if not done already. task.close_input + + # The task has stopped if task.wait returns correctly. return task.wait + rescue Interrupt + # If task.wait is interrupted, we should also interrupt the child process + task.kill ensure + # Print out any remaining data from @output or @error task.close end else return task end end - def initialize(input, output, error, pid) # :nodoc: + def initialize(input, output, error, pid) @input = input @output = output @error = error @pid = pid