How can i safely see that a process is alive

How can i safely see that a process is alive

Post by Stig Simonsso » Wed, 17 Feb 1999 04:00:00



We cannot  trust pid numbers in Unix ,  because they are reused.

Is there a safe way to see if a process is alive from another process ?

We have a application that uses shared library for the API processes.
If we restart our main application we need to know if there is any
API processes out there. We need to map them in to our global memory
region
again after we have restarted the main application.

We have been thinking about locking but can't really see how to check
locks from different processes (pthread_mutex_lock).

Is there some system wide locking in UNIX ??
I'm a VMS person so i don't know that much about UNIX , but i know there

is system and cluster wide locking in VMS !

Maybe one solution is to set a file lock , but rather avoid that !

Regards

Stig Simonsson

 
 
 

How can i safely see that a process is alive

Post by Barry Margoli » Wed, 17 Feb 1999 04:00:00




Quote:>Maybe one solution is to set a file lock , but rather avoid that !

Too bad, that's what I was going to suggest.

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Don't bother cc'ing followups to me.

 
 
 

How can i safely see that a process is alive

Post by Nate Eldredg » Wed, 17 Feb 1999 04:00:00



> We cannot  trust pid numbers in Unix ,  because they are reused.

> Is there a safe way to see if a process is alive from another process ?

> We have a application that uses shared library for the API processes.
> If we restart our main application we need to know if there is any
> API processes out there. We need to map them in to our global memory
> region
> again after we have restarted the main application.

> We have been thinking about locking but can't really see how to check
> locks from different processes (pthread_mutex_lock).

> Is there some system wide locking in UNIX ??

System V style IPC provides semaphores accessible between processes.  I
haven't ever had occasion to use this and so I don't know the details,
but it might be worth investigating.
--

Nate Eldredge

 
 
 

How can i safely see that a process is alive

Post by Sameer Verkhedka » Thu, 18 Feb 1999 04:00:00


Apart from file-locking and inter-process semaphores,

there is another way to do this.

Use a pre-assigned unix port. When your application

starts-up, it can find out whether the port is already

in use. The advantage of this method is that you can

also exchange information during startup using the port.

-Sameer

http://www.cs.arizona.edu/~samverk

 
 
 

How can i safely see that a process is alive

Post by Barry Margoli » Sat, 20 Feb 1999 04:00:00




>It's easy, I dont think it's documented any where but this works:
>send it signal 0, ie:

You obviously didn't read the first sentence of his message.  Since PIDs
can be reused, this won't tell you if it's the process you care about, it
could be some unrelated process that happened to get the same PID.

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

How can i safely see that a process is alive

Post by Casper H.S. Dik - Network Security Engine » Sat, 20 Feb 1999 04:00:00


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


>It's easy, I dont think it's documented any where but this works:
>send it signal 0, ie:
>if(!kill(pid,0))

More like:

        if (kill(pid, 0) == 0 || errno != ESRCH) {
            /* alive */
        }
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

 
 
 

How can i safely see that a process is alive

Post by Chris Wrigh » Tue, 23 Feb 1999 04:00:00




> > We cannot  trust pid numbers in Unix ,  because they are reused.

> > Is there a safe way to see if a process is alive from another process ?

> > We have a application that uses shared library for the API processes.
> > If we restart our main application we need to know if there is any
> > API processes out there. We need to map them in to our global memory
> > region
> > again after we have restarted the main application.

> > We have been thinking about locking but can't really see how to check
> > locks from different processes (pthread_mutex_lock).

> > Is there some system wide locking in UNIX ??

> System V style IPC provides semaphores accessible between processes.  I
> haven't ever had occasion to use this and so I don't know the details,
> but it might be worth investigating.
> --

> Nate Eldredge


System V semaphores could be useful because of the AOE (adjust on exit)
feature.  Using the SEM_UNDO flag with a sem_op means the kernel will
essentially 'undo' the sem_op if the process that performed the sem_op
dies.  For more info, see Advanced Programming in the UNIX Environment
(W.R. Stevens).
 
 
 

1. Am I seeing IPv5, or am I hallucinating?

Yes, you're hallucinating.  The IP version number is 4 bits of the first
byte in the IP header.  The upper 4 bits are the length of the IP header
measured in double-words.  Since the IP header is frequently 20 bytes
long, that 4-bit length field is often '5'.  You're no doubt reading the
wrong field.
--
= Warren -- See the *ix pages at http://www.cyberport.com/~tangent/ix/
=
= ICBM Address: 36.8274040 N, 108.0204086 W, alt. 1714m

2. Dosemu Alt-Ctrl-Fn for vt-Switching

3. Safely forking long perl process in CGI

4. Fresh install conflict with AGP i740

5. ??HOW TO safely share information across all apache Child processes????

6. catman??????

7. how to safely kill the running process?

8. toshiba SCSI cdrom XM5401TA 3605

9. Keeping a child process alive when parent dies

10. Help me - how to know a process is alive or not?

11. How to find a process is alive or die through program?

12. determining if a child process is alive (sunos 4.1.*)

13. How to check (in C) if a process (with known pid) is still alive?