- $USTD --pidfile "$pidfilepath" -s "$SOCKPATH" -o "$OUTDIR" >"$OUTDIR/ustd.log" 2>&1 &
- USTDPID="$(<$pidfilepath)"
- export UST_DAEMON_SOCKET="$SOCKPATH"
+ ${UST_CONSUMERD} --pidfile "$pidfilepath" -s "${UST_CONSUMERD_SOCKPATH}" -o "$OUTDIR" >"$OUTDIR/ust-consumerd.log" 2>&1 &
+ # ust-consumerd sets up its server socket
+ # ust-consumerd opens the pidfile, blocks because no one has opened it
+ # we open pidfile
+ # we block reading pidfile
+ # ust-consumerd writes to pidfile
+ # ust-consumerd closes pidfile
+ # we unblock reading pidfile
+ UST_CONSUMERD_PID="$(<$pidfilepath)"
+ export UST_DAEMON_SOCKET="${UST_CONSUMERD_SOCKPATH}"