From 61b54888993333d96a9aca787d048cf44f75b05a Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Thu, 23 Feb 2023 14:16:45 +0100 Subject: [PATCH] support user defined EXIT traps in init scripts --- iocsh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/iocsh b/iocsh index 2fc79e3..65c686b 100755 --- a/iocsh +++ b/iocsh @@ -437,13 +437,8 @@ done startup=${IOCSH_TMP:-/tmp}/iocsh.startup.$$ # clean up and kill the softIoc when killed by any signal -cleanup() { - trap EXIT - rm -f $startup - stty sane 2> /dev/null - echo -} -trap "kill -s SIGTERM 0; cleanup" EXIT +# execute any exiting exit trap (from init scripts) as well +trap "stty sane 2> /dev/null;echo;rm -f $startup;$(trap -p EXIT | sed 's/.*\x27\(.*\)\x27.*/\1; /')kill -s SIGTERM 0" EXIT { echo "# date=\"$(date)\"" @@ -530,5 +525,4 @@ echo $EXE $ARGS $startup ulimit -c unlimited eval "$LOADER $LOADERARGS $EXE" $ARGS "$startup" 2>&1 STATUS=$? -cleanup exit $STATUS