I have a code like this:
fork();
if child:
execvp("sth"); //Just returns if errors
if parent:
save child pid;
In anther function I want to check if child finished or not, and i don’t want to use waitpid. Is there any other way to do that?
You can set up a signal handler to handle SIGCHLD, which will be delivered to the parent when the child ends. Technically that’s “another function” even if it is called asynchronously. You should still use
waitpideven after getting the signal though and if you have multiple children it is the only way I know that you will be able to tell them apart.