From afb7011ae16a00329a04049171b60bdf763aa530 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sun, 28 Feb 2021 11:41:09 -0700 Subject: [PATCH] install.sh: eliminate spurious test_nc_U "Terminated" messages During the test to see if the configured "nc" command actually supports the `-U` option, the background process that was doing the listening gets explicitly killed. If it has already exited, no problem, the message is suppressed about an invalid PID and the error ignored. If it hasn't, it's killed, but then, at some point, the shell noticies that and wants to write out a "Terminated" notification about the background process. Unless, of course, the shell happens to be running with stderr output redirected to /dev/null at the point it notices. The test_nc_U function always runs with stderr output redirected to /dev/null, but sometimes the terminated process does not get noticed until later. To try and address this, move the first "sleep 1" to immediately after the backgrounding of the listen process to make sure it's really been "exec'd" after forking. Then add another "sleep 1" immediately after the "kill" of the background process as apparently the shell only "notices" that background processes have died just after it's executed an external process. The extra second will not matter to the total time taken for the install process but hopefully will finally squelch the rare spurious "Terminated" message. Signed-off-by: Kyle J. McKay --- install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 51eb2b7..5be264b 100755 --- a/install.sh +++ b/install.sh @@ -442,11 +442,12 @@ test_nc_U() { [ -n "$_tmpdir" ] && [ -d "$_tmpdir" ] || return 1 >"$_tmpdir/output" (sleep 3 | "$_cmdnc" -l -U "$_tmpdir/socket" 2>/dev/null >"$_tmpdir/output" || >"$_tmpdir/failed")& - _bgpid="$!" sleep 1 + _bgpid="$!" echo "testing" | "$_cmdnc" -w 1 -U "$_tmpdir/socket" >/dev/null 2>&1 || >"$_tmpdir/failed" sleep 1 kill "$_bgpid" >/dev/null 2>&1 || : + sleep 1 read -r _result <"$_tmpdir/output" || : _bad= ! [ -e "$_tmpdir/failed" ] || _bad=1 -- 2.11.4.GIT