bug-bash
[Top][All Lists]
Advanced

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

Re: Procsub.tests on OSes using named pipes


From: CHIGOT, CLEMENT
Subject: Re: Procsub.tests on OSes using named pipes
Date: Fri, 14 Feb 2020 14:07:40 +0000

Hi everyone, 

Actually, there is another bug when using named pipes, which might be related 
to my previous patch.
When using named pipe to write from the parent to the child process, the child 
process is blocking in the open syscall of process_substitute() 
(http://git.savannah.gnu.org/cgit/bash.git/tree/subst.c, line 5919).

I'm still investigating but it looks like the write end of the pipe is never 
associated to the parent stdout. Therefore, when the child is trying to open 
the named pipe, it'll wait forever, as said in the man of open:  
>  FIFOs       
>      Opening  the  read or write end of a FIFO blocks until the other end is 
> also opened (by another
>       process or thread).  See fifo(7) for further details.

An easy way to reproduce it is to launch a script with: " moo() { echo "ok";}; 
moo >(true)", you'll see an "ok" in your bash terminal and a subprocess will be 
blocked in an open syscall. The fact that we are seeing this "ok" means that 
the output of the parent process was never redirected to the child. Am I right 
? 

$ cat test_fifo.sh
moo() { echo "ok";}; moo >(true)
$ ../bash.named test_fifo.sh
ok
$ ps -ef | grep test_fifo
root     1145457       1  0 14:53 pts/1    00:00:00 ../bash.named test_fifo.sh
$ stack 1145457
#0  0x00007fff8e81d854 in open64 () from /lib64/libc.so.6
#1  0x00007fff8e81d7c4 in __open_2 () from /lib64/libc.so.6
#2  0x0000000101b7d8dc in open (__oflag=0, __path=<optimized out>) at 
/usr/include/bits/fcntl2.h:57
#3  process_substitute (string=string@entry=0x1002a5f3910 "true", 
open_for_read_in_child=open_for_read_in_child@entry=1) at subst.c:5919
#4  0x0000000101b88244 in expand_word_internal (quoted=quoted@entry=0, 
isexp=isexp@entry=0, 
contains_dollar_at=contains_dollar_at@entry=0x7fffcd53afe4, 
expanded_something=expanded_something@entry=0x7fffcd53afe0, word=<optimized 
out>, word=<optimized out>) at subst.c:9867
... 

In my case, test_fifo.sh is under tests folder of the bash git repository, and 
bash.named is a bash built without "#define HAVE_DEV_FD 1"  (just comment it 
inside config.h).

I'll try to find a patch, but any help would be much appreciated. 

Sincerely, 
Clément






reply via email to

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