Hmmm, if I try to check if a process with a known pid exists I use to
use 
        ``ps -p $PID''
... assuming shell.

If you are talking about C/C++ ... I'd have a look at the source code of
the shell command above. This should show something like your work
around below.

Regards
Frank

On Tue, 2005-03-01 at 02:17 -0600, Hareesh Nagarajan wrote:
> Hi,
> 
> Can a process check if a given PID exists or not? In other words can a
> process check if an unrelated process is alive? Is there any system
> call that does this?
> 
> I can think of a (few) work arounds to this:
> 
> 1. open("/proc/pid_in_question") will return true if the process with
> pid = pid_in_question is alive.
> 
> 2. lock a file called ``pid_in_question". Test the lock from the other
> process.  If the process is dead then there is no lock on the file
> ``pid_in_question".
> 
> Any ideas/comments?
> 
> Thanks,
> 
> Hareesh
> --
> gentoo-user@gentoo.org mailing list
> 
-- 
Frank Schafer
System specialist
T-Systems Czech s.r.o.
Kloboučnická 1435/24, 140 00 Praha 4
Tel.: +420 296529522
Fax: +420 296529129
Mobil: +420 605 202 419
E-mail: [EMAIL PROTECTED]
Internet: http://www.t-systems.cz



--
gentoo-user@gentoo.org mailing list

Reply via email to