I have an assignment to write a program to use fork off a children. That child will the fork off its own child (grandchild of the original parent). The grandchild should exec() to do a ps -ef (for example). The child should wait for its child (grandchild of original parent) to finish successfully. If it didn't finish successfully (I assume that the status return code is 0), it should spawn off another grandchild until it is successful. Once this is complete, it should send the SIGINT signal to its parent.
This is what I was doing, the second time I fork the grandchild, I exec as specified. Here, I set up a signal handler too. In the child, I wait (wait(&status)) and loop while (status != 0). That was the idea.
But, still, I couldn't get the program works. I guess I have the problem with signal handling (?) Can you give me a hint?