All pastes #352487 Raw Edit

Someone

public shellscript v1 · immutable
·published 2007-02-12 21:12 UTC
rendered paste body
# before running the script, do: # mkfifo trigger # echo foo > value  # from another shell, run: # echo 124 > value; echo > trigger  read curval < value  while true; do     while read triggerline; do         read newval < value         if [ "x$newval" != "x$curval" ]; then             echo "value has changed to '$newval'"             curval="$newval"             # fork off child which observes changes until after the             # parent is listening trigger again             {                 sleep 2                 read val < value                 if [ "x$newval" != "x$curval" ]; then                     echo > trigger                 fi             } &         fi     done < trigger     echo "sender has closed pipe, reopening" done