[Top][All Lists]

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

[PATCH] Fix process substitution with named pipes.

From: Michael Haubenwallner
Subject: [PATCH] Fix process substitution with named pipes.
Date: Thu, 31 Oct 2013 16:46:49 +0100

When /dev/fd is missing, and named pipes are used instead (like on AIX),
this snippet sometimes does work right, wrong, or hang - depending on
the operating system's process scheduler timing:

  for x in {0..9}; do echo $x; done > >(
    cnt=0; while read line; do let cnt=cnt+1; done; echo $cnt

To reproduce this problem on Linux, add this line to subst.c to enforce
the problematic timing behaviour:
  #if !defined (HAVE_DEV_FD)
 +      sleep(1);
        fifo_list[nfifo-1].proc = pid;
and enforce using named pipes: bash_cv_dev_fd=absent ./configure ...
 subst.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/subst.c b/subst.c
index 48c89c1..afae3b7 100644
--- a/subst.c
+++ b/subst.c
@@ -5075,7 +5075,7 @@ process_substitute (string, open_for_read_in_child)
 #if !defined (HAVE_DEV_FD)
   /* Open the named pipe in the child. */
-  fd = open (pathname, open_for_read_in_child ? O_RDONLY|O_NONBLOCK : 
+  fd = open (pathname, open_for_read_in_child ? O_RDONLY : O_WRONLY);
   if (fd < 0)
       /* Two separate strings for ease of translation. */

reply via email to

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