diff --git a/test/test_helper.rb b/test/test_helper.rb index 0d86646d..afdd9db5 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -86,12 +86,18 @@ def signal_process(pid, signal, wait: nil) end def process_exists?(pid) + reap_processes Process.getpgid(pid) true rescue Errno::ESRCH false end + def reap_processes + Process.waitpid(-1, Process::WNOHANG) + rescue Errno::ECHILD + end + # Allow skipping AR query cache, necessary when running test code in multiple # forks. The queries done in the test might be cached and if we don't perform # any non-SELECT queries after previous SELECT queries were cached on the connection