From dc788120f745a6eacd9ce39562f7446307eeb2d1 Mon Sep 17 00:00:00 2001 From: Gibson Fahnestock Date: Sat, 1 Apr 2017 19:50:46 +0100 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/12158 --- Makefile | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index a0323f6c81162e..51954445cb2424 100644 --- a/Makefile +++ b/Makefile @@ -265,14 +265,13 @@ test/addons/.buildstamp: config.gypi \ # TODO(bnoordhuis) Force rebuild after gyp update. build-addons: $(NODE_EXE) test/addons/.buildstamp -ifeq ($(OSTYPE),$(filter $(OSTYPE),darwin aix)) - XARGS = xargs -else - XARGS = xargs -r -endif clear-stalled: + # Clean up any leftover processes but don't error if found. ps awwx | grep Release/node | grep -v grep | cat - ps awwx | grep Release/node | grep -v grep | awk '{print $$1}' | $(XARGS) kill + @PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \ + if [ "$${PS_OUT}" ]; then \ + echo $${PS_OUT} | xargs kill; \ + fi test-gc: all test/gc/build/Release/binding.node $(PYTHON) tools/test.py --mode=release gc @@ -300,10 +299,11 @@ test-ci-js: | clear-stalled $(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \ --mode=release --flaky-tests=$(FLAKY_TESTS) \ $(TEST_CI_ARGS) $(CI_JS_SUITES) - # Clean up any leftover processes - PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \ + # Clean up any leftover processes, error if found. + ps awwx | grep Release/node | grep -v grep | cat + @PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \ if [ "$${PS_OUT}" ]; then \ - echo $${PS_OUT} | $(XARGS) kill; exit 1; \ + echo $${PS_OUT} | xargs kill; exit 1; \ fi test-ci: LOGLEVEL := info @@ -312,10 +312,11 @@ test-ci: | clear-stalled build-addons $(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \ --mode=release --flaky-tests=$(FLAKY_TESTS) \ $(TEST_CI_ARGS) $(CI_NATIVE_SUITES) $(CI_JS_SUITES) - # Clean up any leftover processes - PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \ + # Clean up any leftover processes, error if found. + ps awwx | grep Release/node | grep -v grep | cat + @PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \ if [ "$${PS_OUT}" ]; then \ - echo $${PS_OUT} | $(XARGS) kill; exit 1; \ + echo $${PS_OUT} | xargs kill; exit 1; \ fi test-release: test-build