From 8232f1db6950f4c5bc0611a30e9b8f2d70618644 Mon Sep 17 00:00:00 2001 From: Jan Blunck Date: Sun, 18 Oct 2009 22:39:24 +0200 Subject: [PATCH] Fix waiting for ustd on shutdown When starting the daemon use a fifo instead of a pidfile. Otherwise the start races against the reading of the pidfile. During shutdown we should wait for all the existing background shells (there is only one) instead of waiting for the pid of the daemon process. Signed-off-by: Jan Blunck --- usttrace | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usttrace b/usttrace index fe8a5cd..b3af05d 100755 --- a/usttrace +++ b/usttrace @@ -78,7 +78,7 @@ SOCKPATH="/tmp/ust-sock-$$" if [ "$arg_syswide_daemon" != "1" ]; then pidfilepath="/tmp/usttrace-$USER-$(date +%Y%m%d%H%M%S%N)-ustd-pid" - + mkfifo -m 0600 "$pidfilepath" # Start daemon $USTD -d --pidfile "$pidfilepath" -s "$SOCKPATH" -o "$OUTDIR" >"$OUTDIR/ustd.log" 2>&1 & USTDPID="$(<$pidfilepath)" @@ -129,7 +129,7 @@ then kill -SIGTERM "$USTDPID" echo "Waiting for ustd to shutdown..." - wait "$USTDPID" + wait rm "$pidfilepath" fi -- 2.34.1