End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Process.getsid
Process.getsid() → integer
Process.getsid(pid) → integer
process.c
View on GitHub ↗
static VALUE
proc_getsid(int argc, VALUE *argv, VALUE _)
{
rb_pid_t sid;
rb_pid_t pid = 0;
if (rb_check_arity(argc, 0, 1) == 1 && !NIL_P(argv[0]))
pid = NUM2PIDT(argv[0]);
sid = getsid(pid);
if (sid < 0) rb_sys_fail(0);
return PIDT2NUM(sid);
}
Returns the session ID for the given process id. If not given, return current process sid. Not available on all platforms.
Example
Process.getsid() #=> 27422 Process.getsid(0) #=> 27422 Process.getsid(Process.pid()) #=> 27422