Questions tagged [unnamed-pipes]

4 questions
2
votes
1 answer

Reusing a pipe for several messages

I'm writing a code where a parent forks several children, after creating a pipe for each one. In a while loop, the parent aks the user for some input, and communicates it to a child using a pipe, so the child needs to do some stuff about the input.…
2
votes
2 answers

Child process executing parent code (lines before the fork)

I'm having difficulty understanding the behavior of fork(). I thought the child process will execute the lines "after" the fork(). So I expected to see only one "Hello world!", but this code: printf("Hello World!\n"); fork(); return 0; outputs two…
9ganzi
  • 181
  • 10
1
vote
1 answer

What is the importance of adding "\n" to stdout when it's redirected to another process?

So, I'm playing with pipes in c, and I have an exercise where I call a program through command line as this: "./self 1" which then calls itself with execlp but with an argument 2: "./self 2" which further on calls itself with argument 3: "./self 3".…
user410918
  • 15
  • 3
0
votes
1 answer

Problem with reading from named and unnamed pipes at the same time

I am trying to have a process read both from a named pipe and some unnamed pipes. First I have a main process that creates a child process and then initializes a named pipe that waits for data from the terminal to send to the named pipe: int…
Edgar Tip
  • 43
  • 2
  • 7