Creating breadth traversal binary tree

I almost have the entire script written. however the problem is how would i assign the global variable to terminate the process from the bottom up to ensure the child terminates so the parent can.

ex. I am proccess 1
I am proccess 2
etc

Here is the code

$ cat tree.c

main(int argc, Char* argv [])
{
int pid,i;
int j = argv[1];
funcFork(1,1,j);
}

Function funcFork(int Label, int presentLevel, int maxLevel){
Printf(�I am in process %d�,Label);
If (presentLevel == maxLevel)
Return;
pid = fork();
if (pid == 0){
newLabel = Label * 2;
presentLevel ++;
Printf(�I am in process %d�,newLabel);
funcFork(newLabel,presentLevel, maxLevel);
}
Else {
newLabel = Label * 2 + 1;
presentLevel ++;
Printf(�I am in process %d�,newLabel);
funcFork(newLabel,presentLevel, maxLevel);
}

}

Thanks for any help. I don't know if this is allowed but you can also email me at removed.

Please read our rules:

(10) Don't post your email address and ask for an email reply. The forums are for the benefit of all, so all Q&A should take place in the forums.

Is it a Class Home Work

I really have no idea of what that program is supposed to do. But a parent process can use wait() to wait for a child. Also there is nothing wrong with a parent exiting despite the existence of children. init will inherit just the children.