Custom Search

Wednesday, December 26, 2007

Checking if a process is alive or not.

In a multi-processing system - if we want to check if a given child process is alive or not (after forking it) for a longer period of time - we could send a signal 0 to the process using the kill API.


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

int kill(pid_t pid, int sig);


Use this API to send a signal of 0. If the errno is set to ESRCH - then the process had most probably exited.

No comments: