I have found examples of how to fork multiple children by having something like this:
if ( fork() = 0 ) {
//In child
} else {
if ( fork() = 0 ) {
//in second child
But if I don’t know how many children I am going to need, how might I do this?
For instance, if I have a linked list of commands, and I want to fork and exec for each of them… So I guess I need to know which child it is as well…
Taking you at your word that you need to do this for a linked list:
This will launch a separate process for every item in the list.