shell script that waits a specified duration for a process to complete, or exits nonzero on timeout