Parent process id is ppid
We know that every process has a process id. This is usually referred as
pid. In *nix world every process has a parent process. And in ruby the way to get the "process id" of the parent process is through
Let's see it in action. Time to fire up irb.
1irb(main):002:0> Process.pid 2=> 83132 3irb(main):003:0> Process.ppid 4=> 82455
Now keep the irb session open and go to anther terminal tab. In this new tab execute
pstree -p 83132
1$ pstree -p 83132 2-+= 00001 root /sbin/launchd 3 \-+= 00151 nsingh /sbin/launchd 4 \-+= 00189 nsingh /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal -psn_0_45067 5 \-+= 82452 root login -pf nsingh 6 \-+= 82455 nsingh -bash 7 \--= 83132 nsingh irb
pstree is not available then you can easily install it using
brew install pstree.
As you can see from the output the process id 83132 is at the very bottom of the tree. The parent process id is 82455 which belongs to "bash shell".
In irb session when we did
Process.ppid then we got the same value 82455.