[clug] killing a looping / hung script?
david.deaves at dd.id.au
Tue Dec 6 06:43:04 UTC 2016
> 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
More information about the linux