I have three modules(2 C executable+ 1 python script). I need three processes-one parent, two child processes. All of them won't stop until they see an End of file. They just keep running after execution. Problem just arises here. Parent process needs the output of child process 1, and child process 2 needs the output of parent process. The order is: child process 1 outputs result and sleep for 5 seconds before next round of output-> parent process gets that output as input and output its own result -> child process 2 gets its parent's result and output final result to standard output. This is only one iteration. This loop will be repeated again and again until seeing an End of file. I don't know how to make parent process wait for child process 1's each iterations output and forward it to child process 2. So as child process waits for parent process. I considered wait(), but that needs child process 1 to stop. But actually, none of those three process stops before End of file. So, is there any good mechanism to implement this scenario?
Asked
Active
Viewed 208 times
1 Answers
2
You need to implement a pipe mechanism between the processes. Suggest you to go though the man pages of pipe(), dup() and also the link here for more info
-
I know these. But what troubles me is how to signal parent process to fetch data as soon as child process generates it. – Tamier Nov 02 '15 at 21:56
-
As soon as you write into the pipe, the other process will be able to read it, by polling the pipe handle using, for example, poll(). – Arun Nov 03 '15 at 03:01