Plan 9 from Bell Labs’s /usr/web/sources/contrib/someone/root/rc/bin/await

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/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 [arg...]' >[1=2]
	exit usage
}

rfork e
secs=$1
shift

$* &
cmdpid=$apid
secsseq = `{seq $secs}
for (s in $secsseq $secsseq)
	if (test -e /proc/$cmdpid)
		sleep 0.5
if (test -e /proc/$cmdpid) {
	echo $0: $"*: still running >[1=2]
	exit 'still running'
}
exit ''

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.