Supervising non-child processes w/wo procfs

Supervising non-child processes w/wo procfs

Post by Guido Ostkam » Fri, 15 Jun 2001 18:43:20



Hello newsgroup,

within a process I want to supervise a large number of other processes,
which have not been started by the supervising process; the supervising
process just knows the process IDs. Furthermore, supervising should
be realized in a way, which doesn't waste CPU power, i.e. should be
blocking, not actively polling.

In SystemV based systems this can be solved easily, you just have to
open /proc/<pid> for each process and select/poll on the file
descriptors. Whenever a process dies, the supervising process is
informed by kernel and returns from the select/poll.

Unfortunately this doesn't seem to work with Linux.

Is there any implementation of the poll() system call for procfs?

Does somebody know other methods to solve the above problem?

Thanks in advance,

Regards,

Guido

 
 
 

Supervising non-child processes w/wo procfs

Post by Guido Ostkam » Mon, 18 Jun 2001 20:06:25



Quote:>        What exactly do you mean by "supervise"?
>        [...]
>        ...because it sounds like you mean "wait for it to die".  

You are correct. The system is going to provide high-availability,
therefore one feature is that applications which exited, must be
restarted immediately. As it is possible that the supervising process
itself may fail (and will be restared) and processes can also be
restarted manually from outside and put themselves under control
of the supervising process by calling some libraray, there is no
parent-child relationship between them, thus signalling won't work.

Quote:> And it just
> so happens that I recently wrote a program to do this.  Of course, my
> solution was "stat /proc/<pid> && sleep", so it's not quite the way you
> specify, but, as Linus said, it wins on points of being available now!

I cannot use such a solution because it uses active polling. If I do
this often enough to gurantee a certain reaction time, it would waste
too much CPU power. On the other hand I cannot sleep long time, because
restarting would be to slow. Therefore I need a blocking solution.

Quote:>        I assume you have looked at the way some SysV systems do it - I just
> did a truss of pwait on a Solaris 7 system, and saw this
> [...]
>        so it works the way you describe.  The Linux and Solaris poll man
> pages make them look reasonably similar.  You've tried it and it didn't
> work?

Yes. Of course, the poll() or select() library function API is the same,
but the underlying implementation of the poll in the proc filesystem
is different. On Linux, if you are listening for POLLPRI, POLLERR or
POLLHUP events (e.g. when using /proc/<pid>/status), they won't be
detected. When the process dies, nothing happens.

Therefore my question, if someone has implemented the procfs (poll)
the SysV way.

Regards,

Guido

 
 
 

Supervising non-child processes w/wo procfs

Post by AndrĂ© Davi » Wed, 20 Jun 2001 06:26:54




> >        What exactly do you mean by "supervise"?
> >        [...]
> >        ...because it sounds like you mean "wait for it to die".

> You are correct. The system is going to provide high-availability,
> therefore one feature is that applications which exited, must be
> restarted immediately. [...]

From what I read, you might just want to use the init services:

man 5 inittab

HIH,

Andre

  Andre.David.vcf
< 1K Download