Hello

Processes can test the validity of PID's by signalling the PID
with a ZERO signal number. To signal the process you use the
kill() system call. When a zero signal number is used error checking
is done but no signal is sent so that you don't have to worry
about what the process is going to do with a untrapped or
ill-defined interrupt handler

eg.


#include <stdio.h>
#include <signal.h>

main(int argc, char *argv[])
{
  int pidno = atoi(argv[1]);
  if(kill(pidno,0) == 0)
    printf("pid number %d exists\n",pidno);
  else
    printf("pid number %d does not exist (or does not belong to
you)\n",pidno);
  exit(0);
}


The above code will check the pid passed as the first command
line argument to the program. Note that you can't signal arbitrary
processes unless you are the superuser or the process is owned by
your userid.

HTH

Jeff Herrick


On Tue, 3 Sep 2002, Santosh Varma wrote:

> Hello all,
>
>     I get a process id by calling getProcessId()..I want to know from
> program whether that processId exists.
> Any way to find out how ?
>
> Thanks and regards,
> Santosh
>

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Jeff Herrick
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to