# Pricess ID

**URL:** <https://www.ruby-forum.com/t/pricess-id/118306>\
**Category:** Ruby\
**Created:** [October 25, 2007, 3:07pm UTC](https://www.ruby-forum.com/t/pricess-id/118306 "2007-10-25T15:07:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fishman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@fishman2001](https://www.ruby-forum.com/u/fishman2001)\
**Post date:** [October 25, 2007, 3:07pm UTC](https://www.ruby-forum.com/t/pricess-id/118306/1 "2007-10-25T15:07:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fishman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@fishman2001](https://www.ruby-forum.com/u/fishman2001)\
**Post date:** [October 25, 2007, 3:25pm UTC](https://www.ruby-forum.com/t/pricess-id/118306/2 "2007-10-25T15:25:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![fishman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@fishman2001](https://www.ruby-forum.com/u/fishman2001)\
**Post date:** [October 25, 2007, 11:28pm UTC](https://www.ruby-forum.com/t/pricess-id/118306/3 "2007-10-25T23:28:45Z")

</div>

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

> 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
