2 ms·
<command> & sleep <timeout>; kill -SIGALRM %1
by timewizard 1y ago
<command> & sleep <timeout>; kill -SIGALRM %1
- robinhouston 1y agoThat's ok, but %1 will refer to the wrong job if there's already a background job running. You could use %% instead, but that will refer to the wrong job if <command> terminates before the timeout.
- fpoling 1y agoThis always sleep for timeout rather than terminating when the command terminates.