--- /sys/man/1/await Mon Oct 24 20:09:22 2016 +++ /sys/man/1/await Mon Oct 24 00:00:00 2016 @@ -0,0 +1,29 @@ +.TH AWAIT 1 +.SH NAME +await - wait at most some seconds for a command to complete +.SH SYNOPSIS +.B await +.I max-secs +.I cmd +\&... +.SH DESCRIPTION +Run +.I cmd +with any following arguments, +with standard input from +.BR /dev/null . +Wait at most +.IR max-secs ; +if +.I cmd +is then still running, +exit but leave it running. +.PP +Useful in start-up scripts that must not get stuck. +.SH EXAMPLES +.B +await 5 auth/secstore -s p9auth -n -G factotum >/mnt/factotum/ctl +.SH SOURCE +.B /rc/bin/await +.SH SEE ALSO +.IR wait (2) --- /rc/bin/await Mon Oct 24 20:09:22 2016 +++ /rc/bin/await Mon Oct 24 00:00:00 2016 @@ -0,0 +1,21 @@ +#!/bin/rc +# await secs cmd ... - wait at most secs for cmd to complete, but don't kill it. +# cmd's stdin will be /dev/null. +switch ($#*) { +case 0 1 + echo usage: $0: 'maxsecs cmd ...' >[1=2] + exit usage +} + +rfork e +secs=$1 +shift + +$* & +cmdpid=$apid + +for (s in `{seq $secs}) + if (test -e /proc/$cmdpid) + sleep 1 +if (test -e /proc/$cmdpid) + echo $0: $"*: still running >[1=2]