Skip to content

Commit 8b5e823

Browse files
committed
jobutils: More robust return code determination
Sometimes the bash wait falsely claims "PID" not a child of this shell. This commit is working around this issue.
1 parent 5835f06 commit 8b5e823

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Utilities/Tools/jobutils.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ taskwrapper() {
111111
# the command might be a complex block: For the timing measurement below
112112
# it is better to execute this as a script
113113
SCRIPTNAME="${logfile}_tmp.sh"
114-
echo "${command}" > ${SCRIPTNAME}
114+
echo "${command}; echo \"TASK-EXIT-CODE: $?\"" > ${SCRIPTNAME}
115115
chmod +x ${SCRIPTNAME}
116116

117117
# this gives some possibility to customize the wrapper
@@ -372,9 +372,9 @@ taskwrapper() {
372372

373373
# wait for PID and fetch return code
374374
# ?? should directly exit here?
375-
wait $PID
376-
# return code
377-
RC=$?
375+
wait $PID || QUERY_RC_FROM_LOG="ON"
376+
# query return code from log (seems to be safer as sometimes the wait issues "PID" not a child of this shell)
377+
RC=$(grep "TASK-EXIT-CODE:" ${logfile} | awk '//{print $2}')
378378
RC_ACUM=$((RC_ACUM+RC))
379379
if [ "${RC}" -eq "0" ]; then
380380
if [ ! "${JOBUTILS_JOB_SKIPCREATEDONE}" ]; then

0 commit comments

Comments
 (0)