UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » Processes
  • » shared mem: how to know when the other process is not alive

#1 2007-12-03 07:15 PM

darthsidious
Member
Registered: 2007-11-18
Posts: 14

Re: shared mem: how to know when the other process is not alive

hello, well, it's me again.

Maybe someone will know about this. It's the only thing that remains to be done.

i comunicate two procecess in the same machine with Shared Memory, how do i know when the other process is no loger alive, for example, 'cos someone did a kill -9 and it' couldn't close everything properly?

The problem is that semaphores (system V) stop "blocking" when a process dies, and it starts looping like crazy (the readings to de shm segment are inside a loop). I thought that semop would return something like -1 but it didn't happen.


well, thanks!!!

Offline

#2 2007-12-04 01:10 AM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: shared mem: how to know when the other process is not alive

I'm not 100% certain I understand but... if you mean you just want to be able to have a process ( or any process ) to determine if others are still using a semaphore...

One thought might be to have a shared memory segment set up to hold a list / tree / whatever - where on first use of the semaphore - the process accesses and adds its id to the list...

Then if ( another process ) wants to check who is registered and STILL actually alive - it can just iterate through the list and send kill( pid, 0 ) and see if the pid(s) are valid and processes are alive... and so be able to determine - among other things - if any of the previously registered processes have exited for any reason...

Don't know if thats helpful...


Michael


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

  • Index
  • » Processes
  • » shared mem: how to know when the other process is not alive

Board footer

Powered by FluxBB