Re: Kill system call

Marek Michalkiewicz (marekm@i17linuxb.ists.pwr.wroc.pl)
Thu, 21 Mar 1996 19:40:44 +0100 (MET)


Nick Randell:
> I have a process, which forks off a child. The child process has a
> different EUID to the parent. The child sends the parent a signal to
> check that it is still alive, but the kill system call returns EPERM
> whereas on all the other unix systems the software is running on the
> call returns 0.
>
> I have patched the applications source code to check for EPERM on Linux
> but the reply I got mentioned that the Linux kernel handling is
> incorrect.

It may be better to check for ESRCH - if you get this error, you know
this process doesn't exist. This should work everywhere:

if (kill(pid, 0) == -1 && errno == ESRCH) {
/* process doesn't exist ... */
} else {
/* process exists ... */
}

Marek