I have a parent process that forks two children. I need to force a certain order for when these child processes run.
For example, the parent process takes a "command" from a file, and depending on that command, the parent will either pass that command to child a or child b using unnamed pipes. I need stuff to happen in the children in the same order that the parent received the command from the file.
The way I was using semaphores did not work between processes. Any ideas?
Semaphores work just fine between processes. For example:
Output:
If you use IPC semaphores they also work for forks. Look here: http://www.advancedlinuxprogramming.com/alp-folder Chapter 5 will give you the informations you need.