I wanted to check in and see if there was a chance of this feature being 
accepted upstream before I spent any time on it...  so here goes.

The "wait [n]" command is handy, but would be even handier is:

wait [[-a] n]

instead, which asynchronously checks to see if process 'n' has completed.

I.e. this would be like calling waitpid() with options=WNOHANG, instead of 0.

Why bother?

Well, sometimes in scripts (especially /etc/init.d/ scripts) it's useful to do 
something like:

timeout=30
interval=1

pppd ... updetach&
pid=$!

let -i n=0

while [ $n -lt $timeout ]; do
  wait -a $pid
  status=$?

  if [ $status -ne 128 ]; then break; fi

  sleep $interval
fi

if [ $status -ne 0 ]; then
  echo "Couldn't start PPPD or failed to connect.">&2
  exit 1
fi


as an example. (In this case, the original instance of pppd would have forked 
and detached when it successfully connected, causing the original instance to 
exit with 0; anything else would return non-zero.)

Does this seem like a reasonable enhancement?

Thanks,

-Philip


Reply via email to