[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Pricess ID

fish man

10/25/2007 1:07:00 PM

Hi,
if I start a process in Ruby using the system("some process")
how can I get the process id of the process I've just started?

Cheers.
Dan.
--
Posted via http://www.ruby-....

2 Answers

Vellingiri Arul

10/25/2007 1:26:00 PM

0

Fish Man wrote:
> Hi,
> if I start a process in Ruby using the system("some process")
> how can I get the process id of the process I've just started?
>
> Cheers.
> Dan.

Dear Fish Man,
This is very simple.Just you can use Process.pid.
For instance,
I wll give some example,
I am having one file:
1.rb
system("ps") =>execute the process
p Process.pid =>it will tell the current process Id.

/1.rb
Next you can ruby this program.
You can see this output:
PID TTY TIME CMD
18662 pts/2 00:00:00 bash
18962 pts/2 00:00:00 ruby
18963 pts/2 00:00:00 ps
18962
You can combine the ruby process id and last one id is there.Both
are same.
This is way only we can take the process id.Other than that I don't
know.

by
vellingiri.
--
Posted via http://www.ruby-....

Aria Stewart

10/25/2007 9:28:00 PM

0


On Oct 25, 2007, at 7:25 AM, Arul hari wrote:

> Fish Man wrote:
>> Hi,
>> if I start a process in Ruby using the system("some process")
>> how can I get the process id of the process I've just started?
>>
>> Cheers.
>> Dan.
>
> Dear Fish Man,
> This is very simple.Just you can use Process.pid.
> For instance,
> I wll give some example,
> I am having one file:
> 1.rb
> system("ps") =>execute the process
> p Process.pid =>it will tell the current process Id.

But not the one launched by system.

You probably want to use something other than system -- popen, fork/
exec, something like that