Configuration Information [Automatically generated, do not change]: Machine: i686 OS: linux-gnu Compiler: i686-pc-linux-gnu-gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -g -O2 -mtune=pentium-m -pipe uname output: Linux cerise 2.6.24.3 #2 SMP Thu Mar 27 10:43:06 GMT 2008 i686 GNU/Linux Machine Type: i686-pc-linux-gnu
Bash Version: 3.2 Patch Level: 33 Release Status: release Description: If --noediting is used (e.g. for use with Emacs' shell-mode), and a program run from bash sets O_NONBLOCK on bash's stdin, bash reads and executes random garbags until it eventually segfaults. Repeat-By: bash --noediting <any program which leaves the descriptor in non-blocking mode> Fix: The attached patch appears to fix the specific problem. However, I'm still unclear as to how the original problem occurs. It looks as if the errno != EINTR check should result in a busy-wait. --- input.c~ 2006-07-28 02:22:58.000000000 +0100 +++ input.c 2008-06-30 17:28:48.000000000 +0100 @@ -75,6 +75,11 @@ local_bufused = read (fileno (stream), localbuf, sizeof(localbuf)); if (local_bufused > 0) break; + else if (errno == EAGAIN) + { + sh_unset_nodelay_mode (fileno (stream)); + continue; + } else if (local_bufused == 0 || errno != EINTR) { local_index = 0;