PROPHET/OS
NAME
timeout: a run with a deadline
SYNOPSIS
timeout <seconds> <program> [argument ...]|selbsttest
DESCRIPTION
A run with a deadline
It starts the program beside itself and a watch of its own that counts the deadline down. Whoever ends in time gives his own value back, unchanged, so a step that reads the number reads the program's and not this one's. Whoever does not is asked to end, and timeout says so and gives 1.
Asked, not forced: the end goes over SIGNAL_END, which a run obeys at its next call and a sleeping one at once. A program that circles in ring 3 and never calls is not hit by that; for that one there is kill, which bends it out of its circle at the next tick.
A deadline of nothing is refused. It is no deadline, and a tool that takes it would end the run before it began.
This is the last foreign name the build calls that this machine did not have (R10-SELF-06): timeout 180 qemu ... stands three times, so that a run which does not come back does not hold the whole build.
selbsttest drives both ways: a run of a minute against a deadline of a second has to be ended and give 1, and a run that ends at once has to give its own value back and not be taken for one that ran over. It is what shell.a_run_over_its_deadline_is_ended drives.
EXAMPLE
$ timeout --help timeout <seconds> <program> [argument ...]|selbsttest runs the program and asks it to end when the seconds are up 0 when it ended by itself, its own value then, 1 when the deadline ran out