Skip to content

Commit d19809a

Browse files
committed
build: avoid passing kill empty input in Makefile
Using `xargs -r` on some platforms and `xargs` on others doesn't work, we can't guarantee whether xargs is GNU or not. Avoid the issue by only running kill if there are processes to clean. PR-URL: #12158 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 57b850e commit d19809a

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

Makefile

+13-12
Original file line numberDiff line numberDiff line change
@@ -298,14 +298,13 @@ test/addons-napi/.buildstamp: config.gypi \
298298
# TODO(bnoordhuis) Force rebuild after gyp or node-gyp update.
299299
build-addons-napi: $(NODE_EXE) test/addons-napi/.buildstamp
300300

301-
ifeq ($(OSTYPE),$(filter $(OSTYPE),darwin aix))
302-
XARGS = xargs
303-
else
304-
XARGS = xargs -r
305-
endif
306301
clear-stalled:
302+
# Clean up any leftover processes but don't error if found.
307303
ps awwx | grep Release/node | grep -v grep | cat
308-
ps awwx | grep Release/node | grep -v grep | awk '{print $$1}' | $(XARGS) kill
304+
@PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
305+
if [ "$${PS_OUT}" ]; then \
306+
echo $${PS_OUT} | xargs kill; \
307+
fi
309308

310309
test-gc: all test/gc/build/Release/binding.node
311310
$(PYTHON) tools/test.py --mode=release gc
@@ -335,10 +334,11 @@ test-ci-js: | clear-stalled
335334
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
336335
--mode=release --flaky-tests=$(FLAKY_TESTS) \
337336
$(TEST_CI_ARGS) $(CI_JS_SUITES)
338-
# Clean up any leftover processes
339-
PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
337+
# Clean up any leftover processes, error if found.
338+
ps awwx | grep Release/node | grep -v grep | cat
339+
@PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
340340
if [ "$${PS_OUT}" ]; then \
341-
echo $${PS_OUT} | $(XARGS) kill; exit 1; \
341+
echo $${PS_OUT} | xargs kill; exit 1; \
342342
fi
343343

344344
test-ci: LOGLEVEL := info
@@ -347,10 +347,11 @@ test-ci: | clear-stalled build-addons build-addons-napi
347347
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
348348
--mode=release --flaky-tests=$(FLAKY_TESTS) \
349349
$(TEST_CI_ARGS) $(CI_NATIVE_SUITES) addons-napi $(CI_JS_SUITES)
350-
# Clean up any leftover processes
351-
PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
350+
# Clean up any leftover processes, error if found.
351+
ps awwx | grep Release/node | grep -v grep | cat
352+
@PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \
352353
if [ "$${PS_OUT}" ]; then \
353-
echo $${PS_OUT} | $(XARGS) kill; exit 1; \
354+
echo $${PS_OUT} | xargs kill; exit 1; \
354355
fi
355356

356357
test-release: test-build

0 commit comments

Comments
 (0)