Re: [clug] killing a looping / hung script?
"David Deaves" <[email protected]> Tue, 6 Dec 2016 17:43:04 +1100
| Newsgroups | gmane.org.user-groups.clug |
|---|---|
| Message-ID | <[email protected]> |
> I have a perl script which occasionally goes into a hung or wait state, and > wanted to know is there a standard way to automatically kill this process > after some timeout (eg 1 min). > Note the perl script is doing a Serial port read and for some reason it > waits if there is an issue with the Arduino. > > ie can I use some sort of wrapper script to check this state and kill it? > Is there really a problem with the script that needs killing, or is it just that your script is reading from a serial port (from the Arduino) and there is no data coming, so the read is blocking. Really your perl script should be able to handle this internally. Either set the terminal into a mode that the read does not block tcgetattr/tcsetattr, just remember it may now return an empty string. or put a timeout on your read. Even if you want the script to re-start to re-run some initialisation steps, it is still better to detect the problem at the read rather than have some outside agent confuse busy for stalled. Dave ! -- linux mailing list [email protected] https://lists.samba.org/mailman/listinfo/linux