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

Re: [OT] - Bash question: get output as a variable?



On Friday 05 February 2010 16:33:12 Bob McGowan wrote:
> Boyd Stephen Smith Jr. wrote:
> > mkfifo "LOCM" &&
> > mkfifo "FIN" &&
> > (
> > 	"<" | "NFIND" | "LOCATE" 2> "LOCM" | "FANINANY" 2< "FIN"| ">" &
> > 	"LOCATE" < "LOCM" > "FIN" &
> > 	wait
> > )
> 
> which would disallow having the
> "parallel" processing implied by the above diagram.

My example runs in parallel.  It's virtually required when using fifos.  They 
aren't normal files -- only so much data can be written to their internal 
buffer before further writes block.

In this case the shell actually starts at least 6 processes.  One for each 
"utility".  Prior to doing the "exec" call in each process, it sets up the 
pipes and redirection.  It doesn't wait for the processes to finish (notice 
the '&' at the end of the pipelines) until I use the wait shell-builtin.

When the "LOCATE" utility on the second line starts trying to read from stdin 
(LOCM) it will block until the "LOCATE" utility on the second line writes data 
to stderr (LOCM) and more-or-less immediately start working on that data as 
soon as it arrives.  Similarly, "FANINMANY" will block when trying to read 
stderr (FIN) just until the "LOCATE" on the second line writes data out to 
stdout (FIN).
-- 
Boyd Stephen Smith Jr.           	 ,= ,-_-. =.
bss@iguanasuicide.net            	((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy 	 `-'(. .)`-'
http://iguanasuicide.net/        	     \_/

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: