Nicholas Leippe wrote:
kill -USR1 # should do it
$$ # has the pid of the current process--just pass that in to the child
Okay, got it. This sandbox script simulates a blocking call (sleeping
for 2 seconds in this case) in a backgrounded subshell, which signals
when it's done. Thanks Nicholas!
#!/bin/bash
trap "flag=1" SIGUSR1
flag=0
(sleep 2 ; kill -SIGUSR1 $$) &
# Wait for the flag to get raised, or give up after a while:
count=0
while true; do
if [ $flag -eq 1 ]; then
echo Yay, it worked.
break
else
echo Still waiting
let count=$count+1
if [ $count -gt 100 ]; then
echo Giving up
exit 1
fi
fi
sleep 0.1
done
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/