Re: [BUG] reading from FIFO broken

Herbert Xu <[email protected]>
Newsgroups org.kernel.vger.dash
Message-ID <[email protected]>
Herbert Xu <[email protected]> wrote:
> Martijn Dekker <[email protected]> wrote:
>>
>> ...reading from a FIFO is broken, at least on macOS 12.7.5. It seems like the 
>> 'read' command can no longer read anything from a FIFO.
>> 
>> Reproducer:
>> 
>> $ dash -c 'trap "rm fifo" 0; mkfifo fifo;
>>        echo OK >fifo & read r <fifo; echo "${#r}:$r"'
>> 0:
>> 
>> Expected output:
>> 
>> 2:OK
> 
> I can't reproduce this under Linux.  Could you please run it under
> strace for me?

I even tried stubbing out the tee call and replacing it with

	err = -1;

and it still worked with your test case.  This is what I see through
strace on Linux with a stubbed out tee call:

395516 <... close resumed>)             = 0
395516 ioctl(0, TCGETS <unfinished ...>
395517 <... write resumed>)             = 3
395516 <... ioctl resumed>, 0x7ffcf5136a50) = -1 ENOTTY (Inappropriate ioctl for device)
395517 dup2(10, 1 <unfinished ...>
395516 lseek(0, 0, SEEK_CUR <unfinished ...>
395517 <... dup2 resumed>)              = 1
395516 <... lseek resumed>)             = -1 ESPIPE (Illegal seek)
395517 close(10 <unfinished ...>
395516 pipe2( <unfinished ...>
395517 <... close resumed>)             = 0
395516 <... pipe2 resumed>[3, 4], 0)    = 0
395517 exit_group(0 <unfinished ...>
395516 fcntl(3, F_DUPFD_CLOEXEC, 10 <unfinished ...>
395517 <... exit_group resumed>)        = ?
395516 <... fcntl resumed>)             = 11
395516 close(3)                         = 0
395516 fcntl(4, F_DUPFD_CLOEXEC, 10)    = 12
395517 +++ exited with 0 +++
395516 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=395517, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
395516 rt_sigreturn({mask=[]})          = 12
395516 close(4)                         = 0
395516 read(0, "O", 1)                  = 1
395516 read(0, "K", 1)                  = 1
395516 read(0, "\n", 1)                 = 1
395516 wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], WNOHANG, NULL) = 395517
395516 wait4(-1, 0x7ffcf5136b3c, WNOHANG, NULL) = -1 ECHILD (No child processes)
395516 dup2(10, 0)                      = 0
395516 close(10)                        = 0
395516 write(1, "2:OK\n", 5)            = 5
395516 exit_group(0)                    = ?
395516 +++ exited with 0 +++

Cheers,
-- 
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.