Commit 2266efd2 authored by anonym's avatar anonym
Browse files

Test suite: use Process.wait() instead of IO#close() for subprocesses.

IO#close() seems entirely wrong here, and very likely is the cause for
our defunct subprocesses; I thought IO#close() did an implicit
Process.wait(), but it seems to actually just flush buffers and
forcefully close immediately, even if the process has not exited yet.

If this commit fixes our issues I'll do a pass through our other uses
of IO#close() for subprocesses and fix them too.

Will-fix: #17551
parent c3f10629
......@@ -48,7 +48,7 @@ class Display
def screenshot(target)
FileUtils.rm_f(target)
p = IO.popen(['import', '-quality', '100%', '-window', 'root', target])
p.close
Process.wait(p.pid)
assert($?.success?)
assert(File.exists?(target))
ensure
......@@ -61,7 +61,11 @@ class Display
rescue IOError, Errno::ESRCH
# Process has already exited.
end
p.close
begin
Process.wait(p.pid)
rescue Errno::ECHILD
# Process has already exited.
end
rescue NameError
# We aborted before p was assigned, so no clean up needed.
end
......
......@@ -233,7 +233,7 @@ def cmd_helper(cmd, env = {})
env = ENV.to_h.merge(env)
IO.popen(env, cmd) do |p|
out = p.readlines.join("\n")
p.close
Process.wait(p.pid)
ret = $?
assert_equal(0, ret, "Command failed (returned #{ret}): #{cmd}:\n#{out}")
return out
......
......@@ -24,7 +24,7 @@ module OpenCV
err: [:child, :out]
)
out = p.readlines.join("\n")
p.close
Process.wait(p.pid)
case $?.exitstatus
when 0
return out.chomp.split.map { |s| s.to_i }
......@@ -43,7 +43,11 @@ module OpenCV
rescue IOError, Errno::ESRCH
# Process has already exited.
end
p.close
begin
Process.wait(p.pid)
rescue Errno::ECHILD
# Process has already exited.
end
rescue NameError
# We aborted before p was assigned, so no clean up needed.
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment