summaryrefslogtreecommitdiff
path: root/src/core/libs/lib-misc.sh
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2010-12-09 20:07:36 +0100
committerDieter Plaetinck <dieter@plaetinck.be>2010-12-09 20:07:36 +0100
commit65b8e85c05bc0b947390e38f60933b323a8c0446 (patch)
tree12bd4eef032b4ff30d2b40bd97252d27b4a4cf45 /src/core/libs/lib-misc.sh
parentb687a9270d772d7fdacac4e797d35c918bebfc7d (diff)
properly pass on $BACKGROUND_EXIT so that $CONTROLLED_EXIT is set
Diffstat (limited to 'src/core/libs/lib-misc.sh')
-rw-r--r--src/core/libs/lib-misc.sh15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/core/libs/lib-misc.sh b/src/core/libs/lib-misc.sh
index 3f60255..1a75e43 100644
--- a/src/core/libs/lib-misc.sh
+++ b/src/core/libs/lib-misc.sh
@@ -60,7 +60,8 @@ run_background ()
eval "$2" >>$3 2>&1
BACKGROUND_EXIT=$?
debug 'MISC' "run_background done with $1: exitcode (\$BACKGROUND_EXIT): $BACKGROUND_EXIT .Logfile $3"
- echo >> $3
+ echo >> $3
+ echo $BACKGROUND_EXIT > $RUNTIME_DIR/aif-$1-exit
rm -f $RUNTIME_DIR/aif-$1-running
) &
BACKGROUND_PID=$!
@@ -72,16 +73,22 @@ run_background ()
# wait until a process is done
# $1 identifier. WARNING! see above
# $2 pid of a process to kill when done (optional). useful for dialog --no-kill --tailboxbg's pid.
+# returns 0 unless anything failed in the wait_for logic (not tied to the exitcode of the program we actually wait for)
wait_for ()
{
[ -z "$1" ] && die_error "wait_for needs an identifier to known on which command to wait!"
-
+ ret=0
while [ -f $RUNTIME_DIR/aif-$1-running ]
do
sleep 1
done
-
- [ -n "$2" ] && kill $2
+ BACKGROUND_EXIT=$(cat $RUNTIME_DIR/aif-$1-exit) || ret=1
+ rm $RUNTIME_DIR/aif-$1-exit || ret=1
+ if [ -n "$2" ]
+ then
+ kill $2 || ret=1
+ fi
+ ret $ret
}