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.