I am calling a video conversion process in a do ... while
that's looping over a set of files.
Most of the time it works as expected, but occasionally the process gets hung-up on a file and doesn't move on until I kill it. (So it's not unresponsive as such - just useless!)
It's still sending to stdout and stderr, where I can see that it's attempting to read the same index over and over. I can also see that it's not writing any output to a destination file (so it's not doing anything useful).
Can I:
monitor stdout and/or stderr for repetitive items and quit the process if it does it more than a number of times; or
monitor for the destination file and quit the process if it doesn't exist after a timeout; or
quit the process if it fails to complete after a timeout?