Skip to content

Commit 8cf9d15

Browse files
committed
test: use pgrep for better compatibility
pidof is not available on BSD system, while pgrep is present on BSD, Linux and macOS
1 parent 80fd474 commit 8cf9d15

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

test/functional/test_runner.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,12 @@ def run_tests(*, test_list, src_dir, build_dir, tmpdir, jobs=1, enable_coverage=
396396
args = args or []
397397

398398
# Warn if bitcoind is already running
399-
# pidof might fail or return an empty string if bitcoind is not running
400399
try:
401-
if subprocess.check_output(["pidof", "bitcoind"]) not in [b'']:
400+
# pgrep exits with code zero when one or more matching processes found
401+
if subprocess.run(["pgrep", "-x", "bitcoind"], stdout=subprocess.DEVNULL).returncode == 0:
402402
print("%sWARNING!%s There is already a bitcoind process running on this system. Tests may fail unexpectedly due to resource contention!" % (BOLD[1], BOLD[0]))
403-
except (OSError, subprocess.SubprocessError):
403+
except OSError:
404+
# pgrep not supported
404405
pass
405406

406407
# Warn if there is a cache directory

0 commit comments

Comments
 (0)