[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] does bash stop children processes when reading from them
From: |
Chet Ramey |
Subject: |
Re: [Help-bash] does bash stop children processes when reading from them?? |
Date: |
Tue, 25 Nov 2014 08:47:17 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
On 11/25/14, 8:25 AM, Greg Wooledge wrote:
> On Tue, Nov 25, 2014 at 04:09:22AM -0800, R . wrote:
>> alright, say we have this:
>>
>> while read line; do echo "$line"; done < <(func_or_process)
>>
>> when doing piping and redirection, does bash run "func_or_process" all in
>> one go, then dump all the output to an intermediate file then makes use of
>> them for the rest of the commands??
>
> It depends on the platform bash is built for. Process substitution may
> use a FIFO (named pipe), or it may use a special entry in /dev/fd/, or
> it may (I think) use a temporary file.
Only if someone has written and separately distributed a patch to use
temporary files.
>
> On systems with /dev/fd/* (like BSD and Linux), func_or_process is
> executed as a detached background process, with /dev/fd/* reading
> to its output.
>
> On Unix-like systems without /dev/fd/* (like HP-UX), a named pipe is
> created, and func_or_process is executed as a detached background
> process, writing to the named pipe, which is opened for reading by
> the foreground shell.
>
> On systems with neither (like Microsoft Windows?), I think it uses
> a temp file. The func_or_process is executed first, writing to the
> temp file. When it terminates, the rest of the shell command is
> allowed to run, reading from the temp file.
Bash doesn't do this by default. Some systems may emulate pipes using
temporary files, and there may be patches for Windows-like systems that
add support for using temporary files, but bash as distributed doesn't use
them.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/