How to make a channel in C ++

I am looking at the code for a C ++ program that loads the contents of the file more. I don’t quite understand this, so I was wondering if anyone can write pseudo-code for C ++ - a program that passes something else? Why is fork necessary?

+5
source share
3 answers
create pipe
fork process
if child:
  connect pipe to stdin
  exec more
write to pipe

You need fork()to be able to replace the stdin of the child before the call and not wait for the process to complete.

+6
source

You will find your answer exactly here.

+2
source

fork?

, .

$ ls | more

? ( ls, more). , (STDOUT) ls (STDIN) more, .

, ls more , ( ) STDOUT ( STDIN) . , , , , , . ls , more - .

... - - ...

, concurrency, - (, more), . , fork. more ( exec), .


, fork, . , (, ), .

+2

All Articles