Reputation: 3884
Say I have two programs X and Y asking for input from stdin
. X and Y are run using fork()
followed by execve()
from a third from say A.
What is happening is X is scheduled first. When X reaches the scanf statement, Y gets scheduled and X never gets an input. How do I take care of it?
Upvotes: 2
Views: 281
Reputation: 7832
Have A
mediate the input for X
and Y
. A
can create a pipe to and from each child process. It can read a prompt from a pipe, write the prompt to standard output, read the response from standard input, and write the response to the pipe for the child process.
Upvotes: 4