ppid()
public
Returns the process id of the parent of this process. Always returns 0 on
NT. Not available on all platforms.
puts "I am #{Process.pid}"
Process.fork { puts "Dad is #{Process.ppid}" }
produces:
I am 27417
Dad is 27417
Show source
/*
* call-seq:
* Process.ppid => fixnum
*
* Returns the process id of the parent of this process. Always
* returns 0 on NT. Not available on all platforms.
*
* puts "I am #{Process.pid}"
* Process.fork { puts "Dad is #{Process.ppid}" }
*
* <em>produces:</em>
*
* I am 27417
* Dad is 27417
*/
static VALUE
get_ppid()
{
rb_secure(2);
#ifdef _WIN32
return INT2FIX(0);
#else
return INT2FIX(getppid());
#endif
}