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 <jblunck@suse.de>
if [ "$arg_syswide_daemon" != "1" ];
then
pidfilepath="/tmp/usttrace-$USER-$(date +%Y%m%d%H%M%S%N)-ustd-pid"
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)"
# Start daemon
$USTD -d --pidfile "$pidfilepath" -s "$SOCKPATH" -o "$OUTDIR" >"$OUTDIR/ustd.log" 2>&1 &
USTDPID="$(<$pidfilepath)"
kill -SIGTERM "$USTDPID"
echo "Waiting for ustd to shutdown..."
kill -SIGTERM "$USTDPID"
echo "Waiting for ustd to shutdown..."