I am looking for creating child processes for which I can control their order of processing.
Simple example:
You need to use actual inter-process communication to achieve this.
You seem to think that the waitpid()
function has something to do with waiting for a process to print output, but that's not at all what it does.
Create a semaphore in the parent, pass it to both children, and have one child wait on the semaphore before printing and the other one messaging the semaphore after it's done printing.