help-bash
[Top][All Lists]
Advanced

[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: R .
Subject: Re: [Help-bash] does bash stop children processes when reading from them??
Date: Tue, 25 Nov 2014 05:34:42 -0800

thnx for the help... yeah, i messed up with the term... i meant "process" 
substitution.


> Date: Tue, 25 Nov 2014 08:25:03 -0500
> From: address@hidden
> To: address@hidden
> CC: address@hidden
> Subject: Re: [Help-bash] does bash stop children processes when reading from 
> them??
> 
> 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.
> 
> 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.
> 
> I've never used bash on a system without Unix semantics, so I'm just
> speculating about the previous paragraph.
> 
> > or does bash halt the process like sending a SIGTSTP right after 
> > func_or_process flushes it's output buffer?? then uses that value for the 
> > iteration and then SIGCONT it at the very beginning of another iteration?
> 
> If a temp file is used, there won't be signals.  It will just run the
> func_or_process as a normal foreground child and wait() for it.
> 
> > does it matter if it's a function or a process?? i'm asking as i want to 
> > know if it's still worth using command substitution at all.
> 
> THIS IS NOT COMMAND SUBSTITUTION.
> 
> This is PROCESS substitution.
> 
> Command substitution looks like this:  x=$(foo)
> Or like this:  y=`bar`
> 
> Process substitution looks like this:  foo < <(bar)
> Or like this:  bar > >(foo)
> 
> And no, it does not matter whether the command you issue is a function
> or a script or a compiled program.  It will be a child process in any
> case.
                                          

reply via email to

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