summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2020-06-25 19:01:59 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2020-06-25 19:01:59 (EDT)
commite4130541897047fad36a75e4de4dc609177df8b7 (patch)
tree2312fcf4684b12ed659cf59bd0c5cce2fa4477ec
parent772b6483fc8bcf702f093d46d391e61ab337aa6b (diff)
session: Don't exit on signal
Return to caller to allow for more cleanup.
-rw-r--r--src/session.sh12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/session.sh b/src/session.sh
index 32400ce..c4a9b08 100644
--- a/src/session.sh
+++ b/src/session.sh
@@ -25,6 +25,7 @@ session_plat=
session_mountdir=
session_atexit=
session_sigs=
+_session_es=
_session_mount()
{
@@ -66,6 +67,11 @@ _session_umount()
session_end()
{
+ if [ ! -d "${session_root}/prokit/sessions/${session_id}" ]; then
+ # Session already ended by signal. No need for further cleanup.
+ return 0
+ fi
+
trap : ${session_sigs}
${session_atexit}
@@ -106,7 +112,7 @@ _session_handle_sig()
session_end
- exit $((128 + ${sig}))
+ _session_es=$((128 + ${sig}))
}
_session_set_sigs()
@@ -207,6 +213,8 @@ session_exec()
local args=
local session_dir=
+ _session_es=0
+
args=''
for arg in "${@}"; do
arg="'$(printf '%s\n' "${arg}" | sed "s/'/'\\\\''/g")'"
@@ -216,5 +224,5 @@ session_exec()
chroot "${session_root}" /bin/sh -c "cd ${session_dir}; ${args}" || \
return ${?}
- return 0
+ return ${_session_es}
}