help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] How unnamed pipe is done in bash?


From: Greg Wooledge
Subject: Re: [Help-bash] How unnamed pipe is done in bash?
Date: Thu, 19 Jan 2017 17:07:36 -0500
User-agent: Mutt/1.4.2.3i

On Thu, Jan 19, 2017 at 03:51:50PM -0600, Peng Yu wrote:
> Hi, I don't quite understand who unamed pipe is done in bash.

By calling pipe().

> It seems
> unnamed pipe is mapped to a fd in /dev/fd/<id>.

That's an operating system-specific implementation detail.  A script
should not have to worry about that.

> $ cat <(echo xxx)

Oh, you're actually talking about process substitution, not pipes!

Process substitution can be implemented by using named pipes or by
using /dev/fd/* depending on the target platform.  E.g. on Linux it
uses /dev/fd/* and on HP-UX it uses named pipes in /var/tmp.

imadev:~$ uname -a; ls -ld <(echo)
HP-UX imadev B.10.20 A 9000/785 2008897791 two-user license
prw-------   1 wooledg    pgmr             0 Jan 19 17:04 /var/tmp//sh-np.a03751

arc3:~$ uname -a; ls -ld <(echo)
Linux arc3 3.16.0-4-686-pae #1 SMP Debian 3.16.39-1 (2016-12-30) i686 GNU/Linux
lr-x------ 1 wooledg voice 64 Jan 19 17:07 /dev/fd/63 -> pipe:[153773]

Again, the back-end implementation details are specific to each target
platform, and your script should *NOT* depend on them unless you are
doing something really low-level.



reply via email to

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