Martin Wheatley <[email protected]> wrote:
I have recently identified a failure mode in bash(1) scripts that has plagued us with random process failures for over 20 years! The read(1) built-in command has the -t option to specify a timeout on the read and it appears that the TMOUT variable is also honoured as an alternative if it is defined (and this is where I think there is an issue).
Yes, this is documented behavior that has existed for many years.
Since TMOUT can be inheritted from a much 'higher' process a script has no knowledge about whether it has been set or not nor whether the value is appropriate for the script.
If your script is self-contained, and presumably knows what is appropriate for it, why not continue to do as you describe:
I can (and now do) 'unset TMOUT' where I know my scripts are susceptible to this issue but would ask that you consider whether TMOUT should ever be considered when reading from a pipe.
I see arguments both ways. I think it's reasonable not to change the
longstanding behavior, since you have identified a way around it.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU [email protected] http://tiswww.cwru.edu/~chet/
OpenPGP_signature.asc
Description: OpenPGP digital signature
