Fix in wait_for_children()

wait should not be called in a sub-shell
This commit is contained in:
Patrick Van der Veken 2015-09-04 09:57:08 +02:00
parent bc952e64c2
commit be909a8f5b

View File

@ -42,6 +42,7 @@
# @(#) setstat failures with sftp_file() when remote file # @(#) setstat failures with sftp_file() when remote file
# @(#) permissions do not allow (VRF 1.2.1) [Patrick Van der Veken] # @(#) 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-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! # DO NOT CHANGE THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING!
#****************************************************************************** #******************************************************************************
@ -55,7 +56,7 @@
# or LOCAL_CONFIG_FILE instead # or LOCAL_CONFIG_FILE instead
# define the V.R.F (version/release/fix) # 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) # name of the global configuration file (script)
GLOBAL_CONFIG_FILE="manage_ssh.conf" GLOBAL_CONFIG_FILE="manage_ssh.conf"
# name of the local configuration file (script) # name of the local configuration file (script)
@ -817,13 +818,16 @@ do
set -- "$@" "${PID}" set -- "$@" "${PID}"
# wait for sigchild, catching child exit codes is unreliable because # wait for sigchild, catching child exit codes is unreliable because
# the child might have already ended before we get here (caveat emptor) # 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 else
log "child process ${PID} exited [OK]" wait ${PID}
fi if (( $? ))
then
log "child process ${PID} exited [NOK]"
WAIT_ERRORS=$(( WAIT_ERRORS + 1 ))
else
log "child process ${PID} exited [OK]"
fi
fi
done done
# break loop if we have no child PIDs left # break loop if we have no child PIDs left
(($# > 0)) || break (($# > 0)) || break