Example of waitpid() in use?
I know that waitpid() is used to wait for a process to finish, but how would one use it exactly? Here what I want to do is, create two children and wait for the first child to finish, then kill the second child before exiting. //Create two children pid_t child1; pid_t child2; child1 = fork(); //wait for child1 to finish, then kill child2 waitpid() ... child1 { kill(child2) } mf_starboi_8041 Syntax of waitpid() : pid_t waitpid(pid_t pid, int *status, int options); The value of pid can be: < -1 : Wait for any child process whose process group ID is equal to the absolute value of pid . -1 : Wait