How to know the childs PID of a given process?

  • Thread starter Iñaki Baz Castillo
  • Start date
I

Iñaki Baz Castillo

Hi, I know that a Ruby process with PID 1000 (under Linux) has forked 4 tim=
es.=20
How could I know the PID of those childs from any other ruby interpreter?
This is, I just know the PID of the parent (1000).

Of course I could do some hack as inspecting the output of "ps" and inspect=
ing=20
the pid/ppid, but I'd prfer a ppure Ruby method for this.

Thanks for any suggestion.

=2D-=20
I=C3=B1aki Baz Castillo <[email protected]>
 
R

Robert Klemme

Hi, I know that a Ruby process with PID 1000 (under Linux) has forked 4times.
How could I know the PID of those childs from any other ruby interpreter?
This is, I just know the PID of the parent (1000).

Of course I could do some hack as inspecting the output of "ps" and inspecting
the pid/ppid, but I'd prfer a ppure Ruby method for this.

Thanks for any suggestion.

The typical approach is that the forking parent records PIDs of its
children. If that information needs to be propagated you can either
write it to a file or make it available via DRb.

If you need multiple Ruby processes to collaborate I would probably turn
to DRb anyway. In that case you might not even need to record PIDs but
you could have a coordinator where processes register and unregister or
which starts processes itself. It depends on your use case.

Kind regards

robert
 
I

Iñaki Baz Castillo

El Lunes, 4 de Enero de 2010, Robert Klemme escribi=F3:
=20
The typical approach is that the forking parent records PIDs of its
children. If that information needs to be propagated you can either
write it to a file or make it available via DRb.

If you need multiple Ruby processes to collaborate I would probably turn
to DRb anyway. In that case you might not even need to record PIDs but
you could have a coordinator where processes register and unregister or
which starts processes itself. It depends on your use case.

Thanks a lot. The fact is that I'd like not to modify the program whose=20
processes I want to monitor, so I was looking for something as "ps".

Thanks a lot.

=2D-=20
I=F1aki Baz Castillo <[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,696
Latest member
BarbraOLog

Latest Threads

Top