I am writing a simple shell-like program. I'm stuck on writing the pipeline part. (IE: program_A | program_B )
I'm assuming I need to use pipe(), but I'm unsure how to do this exactly.
program_A reads from stdin, then it write to a pipe? The other end of this pipe is read in by program_B (but program_B normally reads from stdin, so how do I redirect it without messing up program_A?). program_B then outputs to stdout.
Do I setup the pipe, let program_A run and output to the pipe, then start program_B (after redirecting stdin to the pipe)?
Question
dontocsata
I am writing a simple shell-like program. I'm stuck on writing the pipeline part. (IE: program_A | program_B )
I'm assuming I need to use pipe(), but I'm unsure how to do this exactly.
program_A reads from stdin, then it write to a pipe? The other end of this pipe is read in by program_B (but program_B normally reads from stdin, so how do I redirect it without messing up program_A?). program_B then outputs to stdout.
Do I setup the pipe, let program_A run and output to the pipe, then start program_B (after redirecting stdin to the pipe)?
Thanks!
Link to comment
Share on other sites
3 answers to this question
Recommended Posts