C - WEXITSTATUS() question

I want to check if an application is still running under C. So far I've been using

int rc;
rc=WEXITSTATUS( [PID here] )

if(rc > 0)
{
   //then I exited
}

I was wondering seeing as WEXITSTATUS in man pages is close to the WAIT() if it was thread blocking and if it was how would I go about making my code non-blocking without threads?

pid_t waitpid(pid_t pid, int *status, int options);
// use WNOHANG as the option

This returns the pid when if the process ended, or it checks and returns right away if the child process is still active.

---------- Post updated at 11:48 ---------- Previous update was at 11:00 ----------

If it is not a child process -

try

errno=0;
if(kill(pid, 0) == 0 )
{
    printf("process running\n");
}
else

{
    if(errno==ESRCH)
        printf("process stopped\n");
    else
    {
        perror("cannot signal the process");
        exit(1);
     }
}

The thing is I'm creating a daemon to check that certain applications are running(via PID) I do not initially launch them(so they are not my children) and I don't really feel like trying to kill something that I'm to prevent from stopping. would waitpid still work even though it's not my child?

if your just checking to see if PID exists. use kill(pid,0); see man page for details.

When you're writing a daemon consider using a lockfile to prevent two instacnes of the daemon from running. Otherwise the kill(pid,0) approach works fine.