test: make pgrep call portable

Fixes (on linux), for example for the ninja formula test:

```
pgrep
-P
83252
{out: :close}}
Invalid preceding regular expressionpgrep: write error: Bad file descriptor
Error: ninja: failed
An exception occurred within a child process:
  BuildError: Failed executing: pgrep -P 83252 {out: :close}
```

Using File:NULL is more portable.
This commit is contained in:
Michka Popoff 2020-09-22 23:35:10 +02:00
parent 36226debb5
commit 9da32e3d93

View File

@ -46,7 +46,7 @@ rescue Exception => e # rubocop:disable Lint/RescueException
error_pipe.close error_pipe.close
ensure ensure
pid = Process.pid.to_s pid = Process.pid.to_s
if which("pgrep") && which("pkill") && system("pgrep", "-P", pid, out: :close) if which("pgrep") && which("pkill") && system("pgrep", "-P", pid, :out => File::NULL)
$stderr.puts "Killing child processes..." $stderr.puts "Killing child processes..."
system "pkill", "-P", pid system "pkill", "-P", pid
sleep 1 sleep 1