dolzenko 0.0.15 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/dolzenko/shell_out.rb +10 -1
- metadata +2 -2
data/lib/dolzenko/shell_out.rb
CHANGED
@@ -145,8 +145,10 @@ module ShellOut
|
|
145
145
|
in_stream = ShellOut.getopt(:in, STDIN, *args)
|
146
146
|
out_stream = ShellOut.getopt(:out, STDOUT, *args)
|
147
147
|
writer = nil
|
148
|
+
spawned_pid = nil
|
148
149
|
ShellOut.with_env(*args) do
|
149
150
|
PTY.spawn(ShellOut.command(*args)) do |r_pty, w_pty, pid|
|
151
|
+
spawned_pid = pid
|
150
152
|
reader = Thread.current
|
151
153
|
writer = Thread.new do
|
152
154
|
while true
|
@@ -187,7 +189,14 @@ module ShellOut
|
|
187
189
|
rescue PTY::ChildExited => e
|
188
190
|
return ShellOut::after(e.status.exitstatus, out_stream, *args)
|
189
191
|
ensure
|
190
|
-
|
192
|
+
if writer
|
193
|
+
writer.kill rescue nil
|
194
|
+
end
|
195
|
+
|
196
|
+
if spawned_pid
|
197
|
+
Process.kill(-9, spawned_pid) rescue nil
|
198
|
+
end
|
199
|
+
|
191
200
|
system "stty #{ old_state }"
|
192
201
|
end
|
193
202
|
end
|