|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
To run something with a timeout, run the task in background, remembering its PID. Then run another backgrounded subshell that sleeps for the timeout period and then kill the origninal task. The stderr of the kill needs to be sent to /dev/null because it will generate an error if the original command has already finished. The outer shell then has to wait for the original command to return. It will do so either because it finished or because the sleep/kill process killed it after the timeout. By then killing the sleep/kill process you can tell whether the timeout was involed or not.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||