From be909a8f5bdc854ba9af163976d26c127fa9a558 Mon Sep 17 00:00:00 2001 From: Patrick Van der Veken Date: Fri, 4 Sep 2015 09:57:08 +0200 Subject: [PATCH] Fix in wait_for_children() wait should not be called in a sub-shell --- manage_ssh.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/manage_ssh.sh b/manage_ssh.sh index ffd4074..82c30ae 100644 --- a/manage_ssh.sh +++ b/manage_ssh.sh @@ -42,6 +42,7 @@ # @(#) setstat failures with sftp_file() when remote file # @(#) permissions do not allow (VRF 1.2.1) [Patrick Van der Veken] # @(#) 2015-08-28: check_config() update (VRF 1.2.2) [Patrick Van der Veken] +# @(#) 2015-09-04: fix in wait_for_children (VRF 1.2.3) [Patrick Van der Veken] # ----------------------------------------------------------------------------- # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING! #****************************************************************************** @@ -55,7 +56,7 @@ # or LOCAL_CONFIG_FILE instead # define the V.R.F (version/release/fix) -MY_VRF="1.2.2" +MY_VRF="1.2.3" # name of the global configuration file (script) GLOBAL_CONFIG_FILE="manage_ssh.conf" # name of the local configuration file (script) @@ -817,13 +818,16 @@ do set -- "$@" "${PID}" # wait for sigchild, catching child exit codes is unreliable because # the child might have already ended before we get here (caveat emptor) - elif $(wait ${PID}) - then - log "child process ${PID} exited [NOK]" - WAIT_ERRORS=$(( WAIT_ERRORS + 1 )) else - log "child process ${PID} exited [OK]" - fi + wait ${PID} + if (( $? )) + then + log "child process ${PID} exited [NOK]" + WAIT_ERRORS=$(( WAIT_ERRORS + 1 )) + else + log "child process ${PID} exited [OK]" + fi + fi done # break loop if we have no child PIDs left (($# > 0)) || break