X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=usttrace;h=52c378dfbd12041636f1630e7b82d49ee51bcbb6;hb=5ab4c5cbc13fe373def19dbfcbf669a60b7c71a9;hp=689cdded2f66b3289f661e2f9ed003a5a9038ac9;hpb=cd81471175c92d96c593c6fe7b7a37cd491d9e78;p=ust.git diff --git a/usttrace b/usttrace index 689cdde..52c378d 100755 --- a/usttrace +++ b/usttrace @@ -77,21 +77,14 @@ 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 -s "$SOCKPATH" -o "$OUTDIR" 2>&1 >"$OUTDIR/ustd.log" & - USTDPID="$!" + $USTD --pidfile "$pidfilepath" -s "$SOCKPATH" -o "$OUTDIR" >"$OUTDIR/ustd.log" 2>&1 & + USTDPID="$(<$pidfilepath)" export UST_DAEMON_SOCKET="$SOCKPATH" fi -# Wait for the daemon to settle -# If we don't, the process may try to connect to its socket before -# it's ready. -# FIXME: is there a way to make sure this works every time? Yes, -# we could have a mode where ustd daemonizes itself. Therefore -# by the time the control returns to the console, it's ready. - -sleep 0.5 - # Establish the environment for the command export UST_TRACE=1 export UST_AUTOPROBE=1 @@ -136,7 +129,9 @@ then kill -SIGTERM "$USTDPID" echo "Waiting for ustd to shutdown..." - wait "$USTDPID" + wait "$(USTDPID)" + + rm "$pidfilepath" fi echo "Trace was output in: " $OUTDIR