delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/03/23/06:27:01

Date: Fri, 23 Mar 2001 13:22:50 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: "Mark E." <snowball3 AT bigfoot DOT com>
Message-Id: <8011-Fri23Mar2001132248+0200-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6
CC: djgpp-workers AT delorie DOT com
In-reply-to: <3AB9FBCD.21158.622AC9@localhost> (snowball3@bigfoot.com)
Subject: Re: pipe() emulation
References: <3AB9425B DOT 11812 DOT 36ACFC AT localhost> <3AB9FBCD DOT 21158 DOT 622AC9 AT localhost>
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: "Mark E." <snowball3 AT bigfoot DOT com>
> Date: Thu, 22 Mar 2001 13:19:09 -0500
> 
> > How is this supposed to be used?  Could you give an example of a
> > real-life usage in Bash?
> 
> pipe() is used by the command substitution and pipeline portions of Bash. In 
> the case of command substituion, Bash essentially does this:
> pipe(fildes)
> dup2(fildes[1], 1) /* write end of pipe now stdout */
> /* perform command */
> /* read command output from read end of pipe */
> 
> Pipelines such as 'a | b' are more complicated:
> pipe(fildes1)
> dup2(fildes1[1], 1) /* Write end of pipe 1 is now stdout */
> /* run 'a' */
> dup2(fildes1[0], 0) /* Read in of pipe 1 is now stdin */
> close(fildes1[1]) /* Done with write end of pipe 1*/
> /* run 'b' */
> close(fildes1[0]) /* Done with read end of pipe 1 */

Thanks for the explanations.

I really think Bash should have used `popen'/`pclose' in this case.
Since we don't support fork, you'd need to change the Bash sources
anyway; if they used `popen' for systems such as DJGPP, the original
sources would not need to be hacked.

But, if it helps to port Bash, then as long as the docs says that
users should not be tempted to do a fork/exec after a call to `pipe',
I think it's okay to add this.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019