Skip to content

Commit 4d062a4

Browse files
authored
Merge pull request #332 from robbevp/fix/stop-service-exit
Cleanly stop a service group if a service exits
2 parents dd6b809 + 81e38d4 commit 4d062a4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

modules/services.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@ let
7373
pid=$!
7474
echo $pid > "$PRJ_DATA_DIR/pids/${gName}.pid"
7575
on_stop() {
76-
kill -TERM $pid
76+
if ps -p $pid > /dev/null; then
77+
kill -TERM $pid
78+
fi
7779
rm "$PRJ_DATA_DIR/pids/${gName}.pid"
7880
wait $pid
7981
}
80-
trap "on_stop" SIGINT SIGTERM SIGHUP
82+
trap "on_stop" SIGINT SIGTERM SIGHUP EXIT
8183
wait $pid
8284
'').outPath;
8385
}

0 commit comments

Comments
 (0)