225 reputation
26
bio website marnach.net
location London, United Kingdom
age 37
visits member for 3 years, 6 months
seen Nov 14 at 19:21

Mathematician and software engineer.

You can contact me at sven (at) marnach (dot) net.


Feb
8
comment Two pipes to one command
...as demonstrated in this small and stupid test program. After compiling to a, I called it as ./a <(ls), and it successfully printed the list of files, proving the named file decriptor (63 in my case) was already open. The bash might use named pipes in a temporary directory on different architectures than Linux, in which case no additional file descriptors would be open when entering the main process.
Feb
8
comment Two pipes to one command
@WilliamPursell: There are no files involved. The shell creates an anonymous pipe using pipe() and then forks the subprocesses. The main process does have additional file descriptors open if an anonymous pipe is used. These additional file descriptors are passed in the form /dev/fd/..., and the process will usually simply open them using these file names. This will lead to them being dup()ed, creating even more open file descriptors. The process could also use the named file descriptor right away without any open calls...
Feb
8
comment Two pipes to one command
@WilliamPursell: As the above examples demonstrate, at least on my Linux box the latter approach is taken. But "files" in /dev/fd are just place holders for file descriptors with the number given in the file name. Opening a file in dev/fd is the same as dup()ing the respective file descriptor.
Feb
8
comment Two pipes to one command
@iblue: I don't think it's called "temporary pipes". It's just pipes, as created by the pipe() system call.
Jun
4
comment What are your favorite *painful* Unix moments
If you want to match all dotfiles except for . and .., use .[^.]*. (Well, this will actually miss all files starting with .., but usually there is only one.)