Last active
October 26, 2020 12:29
-
-
Save hochan222/9ec4c2ae8933c317897174f7529154ad to your computer and use it in GitHub Desktop.
mac bash shell timeout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(echo 'hello world') & sleep 1; kill $! 2> /dev/null || : |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(echo 'hello world')
Command to execute
& sleep 1;
Maximum time to wait
kill $!
Kill the most recently run process in the background
2> /dev/null
ignores errors thrown by kill
|| :
ignores the "fail" exit code when your code executes in less than the set number of seconds.