Skip to content

Instantly share code, notes, and snippets.

@bhcleek
Last active August 29, 2015 14:14
Show Gist options
  • Save bhcleek/d31dee03b9fda9fb56c6 to your computer and use it in GitHub Desktop.
Save bhcleek/d31dee03b9fda9fb56c6 to your computer and use it in GitHub Desktop.
waitfor.sh
PIPE=$(mktemp -d -t pipe.XXXXXX) && mkfifo $PIPE/pipe && exec 3<> $PIPE/pipe && rm -rf $PIPE
OUTPUTTER &>&3 & # substitute OUTPUTTER for the command whose output should be awaited
LOG_PID=$!
grep -m1 "$1" <&3
kill -SIGTERM $LOG_PID
exec 3<&- #close our pipe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment