Hi, I know that a Ruby process with PID 1000 (under Linux) has forked 4 times.
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.
···
--
Iñaki Baz Castillo <ibc@aliax.net>
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
···
On 01/04/2010 11:52 AM, Iñaki Baz Castillo wrote:
Hi, I know that a Ruby process with PID 1000 (under Linux) has forked 4 times. 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.
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
Thanks a lot. The fact is that I'd like not to modify the program whose
processes I want to monitor, so I was looking for something as "ps".
Thanks a lot.
···
El Lunes, 4 de Enero de 2010, Robert Klemme escribió:
On 01/04/2010 11:52 AM, Iñaki Baz Castillo wrote:
> Hi, I know that a Ruby process with PID 1000 (under Linux) has forked 4
> times. 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.
--
Iñaki Baz Castillo <ibc@aliax.net>
Really interesting, thanks a lot!
···
El Lunes, 4 de Enero de 2010, Daniel Berger escribió:
On Jan 4, 7:21 am, Iñaki Baz Castillo <i...@aliax.net> wrote:
> El Lunes, 4 de Enero de 2010, Robert Klemme escribió:
> > On 01/04/2010 11:52 AM, Iñaki Baz Castillo wrote:
> > > Hi, I know that a Ruby process with PID 1000 (under Linux) has forked
> > > 4 times. 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.
>
> Thanks a lot. The fact is that I'd like not to modify the program whose
> processes I want to monitor, so I was looking for something as "ps".
GitHub - djberg96/sys-proctable: A cross-platform Ruby interface for gathering process information on your operating system
--
Iñaki Baz Castillo <ibc@aliax.net>
There is a typo in the README:
gem install sys-proctalbe --platform linux # Linux
(note "proctalbe") 
···
El Lunes, 4 de Enero de 2010, Daniel Berger escribió:
GitHub - djberg96/sys-proctable: A cross-platform Ruby interface for gathering process information on your operating system
--
Iñaki Baz Castillo <ibc@aliax.net>