Commit 5740245e authored by anonym's avatar anonym
Browse files

Test suite: clean up when try_for() aborts subprocess execution.

If these methods are called from within a try_for() block and the
timeout occurs when running the IO.popen() call, but before the
p.close(), then we get a lingering defunct process. So let's ensure
the processes are cleaned up even in that case.

Will-fix: #17551
parent 63e1165f
......@@ -51,6 +51,20 @@ class Display
p.close
assert($?.success?)
assert(File.exists?(target))
ensure
# If this method is run inside try_for() we might abort anywhere
# in the above code, possibly leaving defunct process around, so
# let's ensure such messes are cleaned up.
begin
begin
Process.kill("KILL", p.pid)
rescue IOError
# Process has already exited.
end
p.close
rescue NameError
# We aborted before p was assigned, so no clean up needed.
end
end
end
......@@ -33,6 +33,20 @@ module OpenCV
else
raise OpenCVInternalError.new(out)
end
ensure
# If this method is run inside try_for() we might abort anywhere
# in the above code, possibly leaving defunct process around, so
# let's ensure such messes are cleaned up.
begin
begin
Process.kill("KILL", p.pid)
rescue IOError
# Process has already exited.
end
p.close
rescue NameError
# We aborted before p was assigned, so no clean up needed.
end
end
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