[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Using TMOUT as default for read bultin is unwise
From: |
Wheatley, Martin R |
Subject: |
Using TMOUT as default for read bultin is unwise |
Date: |
Wed, 14 Sep 2011 09:46:11 +0100 (BST) |
Configuration Information [Automatically generated, do not change]:
Machine: sparc
OS: solaris2.7
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='sparc'
-DCONF_OSTYPE='solaris2.7' -DCONF_MACHTYPE='sparc-sun-solaris2.7'
-DCONF_VENDOR='sun' -DLOCALEDIR='/usr/local/depot/bash-3.2.17/share/locale'
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DSOLARIS -I. -I. -I./include
-I./lib -g -O2
uname output: SunOS gen-off-11 5.10 Generic_144488-17 sun4u sparc
SUNW,SPARC-Enterprise
Machine Type: sparc-sun-solaris2.7
Bash Version: 3.2
Patch Level: 17
Release Status: release
Description:
The contents of the environment variable TMOUT are used are the
default timeout for the read builtin command when reading from
a TTY or pipe AND as a shell command input idle time.
This can lead to random failures of shell scripts
Repeat-By:
Take the following example script snippet...
ACQcommand | while read action
do
executeTheAction "$action"
done
Assume that ACQcommand generates output at around 90 second intervals
and does so day-in/day-out until it needs to terminate because
of an error condition.
If a user has TMOUT=0 or TMOUT set to a value that is significantly
greater than 90 in their profile then the above works fine.
IF TMOUT is < 90 then the above fails repeatedly.
If TMOUT=90 then the above sometimes works and sometimes fails.
Also,
the -t option to read allows a specific timeout to be set to override
the default timeout (as defined by TMOUT) BUT specifing "-t 0" does NOT
disable
the timeout - which means that the only reliable way to have a read NOT
time-out
is to use...
TMOUT=0 read junk
Since a user may assert TMOUT to any value at any time then any script
that uses 'read' can randomly fail - which must surely be undesirable.
Fix:
I think the TMOUT should not be overloaded and its use as a default
value
for the read builtin - especially for sub-shell pipelines is dangerous
and should be discontinued otherwise all bash scripts that use the read
builtin
need to be modified to include TMOUT=0.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Using TMOUT as default for read bultin is unwise,
Wheatley, Martin R <=