Skip to content

Commit 4ef7c2f

Browse files
committed
pcscd: kill orphans
1 parent 686892d commit 4ef7c2f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

AppRun

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,20 @@ export PCSCLITE_CONFIG_DIR="${APPDIR}/etc/reader.conf.d"
2020
PCSCD_RUN_DIR="/tmp/pcscd/run"
2121
rm -rf "${PCSCD_RUN_DIR}"
2222
mkdir -p "${PCSCD_RUN_DIR}"
23+
24+
cleanup_pcscd() {
25+
if [ -n "$PCSCD_PID" ] && kill -0 "$PCSCD_PID" 2>/dev/null; then
26+
echo "Killing pcscd process $PCSCD_PID"
27+
kill "$PCSCD_PID" 2>/dev/null
28+
wait "$PCSCD_PID" 2>/dev/null
29+
fi
30+
}
31+
32+
trap cleanup_pcscd EXIT TERM INT
33+
2334
echo "starting pcscd with ${APPDIR}/usr/bin/pcscd --foreground --auto-exit &"
2435
"${APPDIR}/usr/bin/pcscd" --foreground --auto-exit &
36+
PCSCD_PID=$!
2537

2638
DEFAULT_LANG=en_US.UTF-8
2739
if [[ "$LANG" == "C.UTF-8" ]]

0 commit comments

Comments
 (0)