bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bash ignores some commands if stdin is a FIFO after "read Input < file".


From: Keegan, David
Subject: Bash ignores some commands if stdin is a FIFO after "read Input < file".
Date: Fri, 9 Feb 2001 04:54:29 -0500

From: dkeegan
To: chet@po.cwru.edu
Subject: [Bash ignores some commands if stdin is a FIFO after "read Input
<file"]

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' -DSHELL -DHAVE_CONFIG_H  -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -I.  -I. -I./include -I./lib
-I/usr/local/include -g -O2
uname output: SunOS dlsparc9 5.7 Generic_106541-12 sun4u sparc
SUNW,Ultra-250
Machine Type: sparc-sun-solaris2.7

Bash Version: 2.05, also affects bash-2.04.
Patch Level: 0
Release Status: beta1

Description:
        Bash is being run as a co-process, so its stdin, stdout, and stderr
are piped from/to
      a driver application.

      Initially bash reads one character at a time from stdin (as traced by
"truss -p") and
      works as expected. However after executing "read Input <file", its
input mode
      changes permanently to reading a buffer of several characters at a
time. In this mode
      if the driving application sends two commands terminated by endlines
in quick succession#
      to bash's stdin, such that bash reads them in a single read(), and if
the first is an
      external command requiring a fork, then the second command is ignored
by bash and is not
      executed.

      The truss trace indicates that immediately before the fork(), bash
tries to lseek() stdin,
      which fails because it is a FIFO (ESPIPE), which may offer a clue:

      read(0, 0x000B7D50, 1)            (sleeping...)
read(0, " r", 1)                                = 1
read(0, " e", 1)                                = 1
read(0, " a", 1)                                = 1
read(0, " d", 1)                                = 1
read(0, "  ", 1)                                = 1
read(0, " X", 1)                                = 1
read(0, " x", 1)                                = 1
read(0, " x", 1)                                = 1
read(0, "  ", 1)                                = 1
read(0, " <", 1)                                = 1
read(0, " $", 1)                                = 1
read(0, " t", 1)                                = 1
read(0, " /", 1)                                = 1
read(0, " t", 1)                                = 1
read(0, " .", 1)                                = 1
read(0, " s", 1)                                = 1
read(0, " h", 1)                                = 1
read(0, "\n", 1)                                = 1
open64("/part1/dkeegan/t/t.sh", O_RDONLY)       = 3
fcntl(0, F_GETFD, 0x00000000)                   = 0
fcntl(0, F_DUPFD, 0x0000000A)                   = 10
fcntl(0, F_GETFD, 0x00000000)                   = 0
fcntl(10, F_SETFD, 0x00000001)                  = 0
fcntl(3, F_DUP2FD, 0x00000000)                  = 0
fstat64(0, 0xFFBEBCE0)                          = 0
llseek(0, 0, SEEK_CUR)                          = 0
close(3)                                        = 0
ioctl(0, TCGETA, 0xFFBEBCFC)                    Err#25 ENOTTY
llseek(0, 0, SEEK_CUR)                          = 0
read(0, " # ! / b i n / s h\n e c".., 128)      = 28
llseek(0, 0xFFFFFFFFFFFFFFEE, SEEK_CUR)         = 10
fcntl(10, F_DUP2FD, 0x00000000)                 = 0
fcntl(10, F_GETFD, 0x00000000)                  = 1
close(10)                                       = 0
getcontext(0xFFBEBF10)
read(0, 0x000A7C50, 28)         (sleeping...)
read(0, " h o s t n a m e\n e c h".., 28)       = 19
stat64(".", 0xFFBEBC78)                         = 0
stat64(".", 0xFFBEBA60)                         = 0
stat64("./hostname", 0xFFBEBAF8)                Err#2 ENOENT
stat64("/part1/dkeegan/u/hostname", 0xFFBEBAF8) Err#2 ENOENT
stat64("/part1/dkeegan/b/s/hostname", 0xFFBEBAF8) Err#2 ENOENT
stat64("/part1/dkeegan/bin/s/hostname", 0xFFBEBAF8) Err#2 ENOENT
stat64("/usr/local/bin/hostname", 0xFFBEBAF8)   Err#2 ENOENT
stat64("/usr/local/jdk-1.3.0/bin/hostname", 0xFFBEBAF8) Err#2 ENOENT
stat64("/usr/local/netscape/hostname", 0xFFBEBAF8) Err#2 ENOENT
stat64("/usr/local/samba/bin/hostname", 0xFFBEBAF8) Err#2 ENOENT
stat64("/part2/dkeegan/sof/1/bin/hostname", 0xFFBEBAF8) Err#2 ENOENT
stat64("/part2/dkeegan/sof/1/db/bin/hostname", 0xFFBEBAF8) Err#2 ENOENT
stat64("/part2/dkeegan/sof/1/bin/hostname", 0xFFBEBAF8) Err#2 ENOENT
stat64("/part2/dkeegan/sof/1/db/bin/hostname", 0xFFBEBAF8) Err#2 ENOENT
stat64("/usr/dt/bin/hostname", 0xFFBEBAF8)      Err#2 ENOENT
stat64("/usr/openwin/bin/hostname", 0xFFBEBAF8) Err#2 ENOENT
stat64("/bin/hostname", 0xFFBEBAF8)             = 0
stat64("/bin/hostname", 0xFFBEBAF8)             = 0
brk(0x0016E000)                                 = 0
sigprocmask(SIG_BLOCK, 0xFFBEBEC0, 0xFFBEBEB0)  = 0
llseek(0, 0xFFFFFFFFFFFFFFF6, SEEK_CUR)         Err#29 ESPIPE
fork()                                          = 29770
sigprocmask(SIG_SETMASK, 0xFFBEBEB0, 0x00000000) = 0
    Received signal #18, SIGCLD [caught]
      siginfo: SIGCLD CLD_EXITED pid=29770 status=0x0000
waitid(P_ALL, 0, 0xFFBEB970, WEXITED|WTRAPPED|WNOHANG) = 0
waitid(P_ALL, 0, 0xFFBEB970, WEXITED|WTRAPPED|WNOHANG) Err#10 ECHILD
setcontext(0xFFBEBB98)
sigprocmask(SIG_BLOCK, 0xFFBEBFD0, 0xFFBEBFC0)  = 0
sigprocmask(SIG_SETMASK, 0xFFBEBFC0, 0x00000000) = 0
sigprocmask(SIG_BLOCK, 0xFFBEBFD0, 0xFFBEBFC0)  = 0
sigaction(SIGINT, 0xFFBEBE90, 0xFFBEBF10)       = 0
sigprocmask(SIG_BLOCK, 0xFFBEBED0, 0xFFBEBEC0)  = 0
sigprocmask(SIG_SETMASK, 0xFFBEBEC0, 0x00000000) = 0
sigprocmask(SIG_BLOCK, 0xFFBEBED0, 0xFFBEBEC0)  = 0
sigprocmask(SIG_SETMASK, 0xFFBEBEC0, 0x00000000) = 0
sigprocmask(SIG_SETMASK, 0xFFBEBFC0, 0x00000000) = 0
sigaction(SIGINT, 0xFFBEBE20, 0xFFBEBEA0)       = 0
getcontext(0xFFBEBF10)
sigprocmask(SIG_BLOCK, 0xFFBEB5B8, 0xFFBEB5A8)  = 0
sigprocmask(SIG_SETMASK, 0xFFBEB5A8, 0x00000000) = 0
sigprocmask(SIG_BLOCK, 0xFFBEB5B8, 0xFFBEB5A8)  = 0
sigprocmask(SIG_SETMASK, 0xFFBEB5A8, 0x00000000) = 0
read(0, 0x000A7C50, 28)         (sleeping...)
read(0, " e c h o   $ B A S H _ V".., 28)       = 19
write(1, " 2 . 0 5 . 0 ( 1 ) - b e".., 16)      = 16
getcontext(0xFFBEBF10)
sigprocmask(SIG_BLOCK, 0xFFBEB5B8, 0xFFBEB5A8)  = 0
sigprocmask(SIG_SETMASK, 0xFFBEB5A8, 0x00000000) = 0
sigprocmask(SIG_BLOCK, 0xFFBEB5B8, 0xFFBEB5A8)  = 0
sigprocmask(SIG_SETMASK, 0xFFBEB5A8, 0x00000000) = 0
read(0, 0x000A7C50, 28)         (sleeping...)
read(0, " h o s t n a m e\n e c h".., 28)       = 18
stat64("./hostname", 0xFFBEBCE8)                Err#2 ENOENT
sigprocmask(SIG_BLOCK, 0xFFBEBEC0, 0xFFBEBEB0)  = 0
llseek(0, 0xFFFFFFFFFFFFFFF7, SEEK_CUR)         Err#29 ESPIPE
fork()                                          = 29772
sigprocmask(SIG_SETMASK, 0xFFBEBEB0, 0x00000000) = 0
    Received signal #18, SIGCLD [caught]
      siginfo: SIGCLD CLD_EXITED pid=29772 status=0x0000
waitid(P_ALL, 0, 0xFFBEB970, WEXITED|WTRAPPED|WNOHANG) = 0
waitid(P_ALL, 0, 0xFFBEB970, WEXITED|WTRAPPED|WNOHANG) Err#10 ECHILD
setcontext(0xFFBEBB98)
sigprocmask(SIG_BLOCK, 0xFFBEBFD0, 0xFFBEBFC0)  = 0
sigprocmask(SIG_BLOCK, 0xFFBEBF40, 0xFFBEBF30)  = 0
sigprocmask(SIG_SETMASK, 0xFFBEBF30, 0x00000000) = 0
sigprocmask(SIG_SETMASK, 0xFFBEBFC0, 0x00000000) = 0
sigprocmask(SIG_BLOCK, 0xFFBEBFD0, 0xFFBEBFC0)  = 0
sigaction(SIGINT, 0xFFBEBE90, 0xFFBEBF10)       = 0
sigprocmask(SIG_BLOCK, 0xFFBEBED0, 0xFFBEBEC0)  = 0
sigprocmask(SIG_SETMASK, 0xFFBEBEC0, 0x00000000) = 0
sigprocmask(SIG_BLOCK, 0xFFBEBED0, 0xFFBEBEC0)  = 0
sigprocmask(SIG_SETMASK, 0xFFBEBEC0, 0x00000000) = 0
sigprocmask(SIG_SETMASK, 0xFFBEBFC0, 0x00000000) = 0
sigaction(SIGINT, 0xFFBEBE20, 0xFFBEBEA0)       = 0
getcontext(0xFFBEBF10)
sigprocmask(SIG_BLOCK, 0xFFBEB5B8, 0xFFBEB5A8)  = 0
sigprocmask(SIG_SETMASK, 0xFFBEB5A8, 0x00000000) = 0
sigprocmask(SIG_BLOCK, 0xFFBEB5B8, 0xFFBEB5A8)  = 0
sigprocmask(SIG_SETMASK, 0xFFBEB5A8, 0x00000000) = 0
read(0, 0x000A7C50, 28)         (sleeping...)
read(0, " e c h o   X x x\n e c h".., 28)       = 18
write(1, " X x x\n", 4)                         = 4
getcontext(0xFFBEBF10)
sigprocmask(SIG_BLOCK, 0xFFBEB5B8, 0xFFBEB5A8)  = 0
sigprocmask(SIG_SETMASK, 0xFFBEB5A8, 0x00000000) = 0
sigprocmask(SIG_BLOCK, 0xFFBEB5B8, 0xFFBEB5A8)  = 0
sigprocmask(SIG_SETMASK, 0xFFBEB5A8, 0x00000000) = 0
write(1, " Y y y\n", 4)                         = 4
getcontext(0xFFBEBF10)
sigprocmask(SIG_BLOCK, 0xFFBEB5B8, 0xFFBEB5A8)  = 0
sigprocmask(SIG_SETMASK, 0xFFBEB5A8, 0x00000000) = 0
sigprocmask(SIG_BLOCK, 0xFFBEB5B8, 0xFFBEB5A8)  = 0
sigprocmask(SIG_SETMASK, 0xFFBEB5A8, 0x00000000) = 0
read(0, 0x000A7C50, 28)         (sleeping...) 

Repeat-By:
      These commands were entered in an emacs shell buffer. The hostname and
echo commands
      were sent together by typing ^J rather than <ENTER> between them to
simulate the behaviour
      of the driver application.
     
        $ cat | bash
read Xxx <$t/t.sh
hostname
echo $Xxx
dlsparc9
echo $BASH_VERSION
2.05.0(1)-beta1
hostname
echo Xxx
dlsparc9
echo Xxx
echo Yyy
Xxx
Yyy

Regards,
David Keegan.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]