Just check status process in c

Then you want to use the waitpid function with the WNOHANG option:

#include <sys/types.h>
#include <sys/wait.h>

int status;
pid_t return_pid = waitpid(process_id, &status, WNOHANG); /* WNOHANG def'd in wait.h */
if (return_pid == -1) {
    /* error */
} else if (return_pid == 0) {
    /* child is still running */
} else if (return_pid == process_id) {
    /* child is finished. exit status in   status */
}

Leave a Comment