Project

General

Profile

Feature #6757 ยป 0001-process.c-add-Process.getsid.patch

fumiyas (Fumiyasu SATOH), 07/20/2012 11:47 AM

View differences:

configure.in
1557 1557
	      getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\
1558 1558
	      getpriority getrlimit setrlimit sysconf close getpwnam_r getgrnam_r\
1559 1559
	      dlopen sigprocmask sigaction sigsetjmp _setjmp _longjmp\
1560
	      setsid telldir seekdir fchmod cosh sinh tanh log2 round llabs\
1560
	      getsid setsid telldir seekdir fchmod cosh sinh tanh log2 round llabs\
1561 1561
	      setuid setgid daemon select_large_fdset setenv unsetenv\
1562 1562
              mktime timegm gmtime_r clock_gettime gettimeofday poll ppoll\
1563 1563
              pread sendfile shutdown sigaltstack dl_iterate_phdr\
process.c
4100 4100
#endif
4101 4101

  
4102 4102

  
4103
#ifdef HAVE_GETSID
4104
/*
4105
 *  call-seq:
4106
 *     Process.getsid(pid)   -> integer
4107
 *
4108
 *  Returns the session ID for this process. Not available on
4109
 *  all platforms.
4110
 *
4111
 *     Process.getsid(0)               #=> 27422
4112
 *     Process.getsid(Process.pid())   #=> 27422
4113
 */
4114

  
4115
static VALUE
4116
proc_getsid(VALUE obj, VALUE pid)
4117
{
4118
    rb_pid_t sid;
4119

  
4120
    rb_secure(2);
4121
    sid = getsid(NUM2PIDT(pid));
4122
    if (sid < 0) rb_sys_fail(0);
4123
    return PIDT2NUM(sid);
4124
}
4125
#else
4126
#define proc_getsid rb_f_notimplement
4127
#endif
4128

  
4129

  
4103 4130
#if defined(HAVE_SETSID) || (defined(HAVE_SETPGRP) && defined(TIOCNOTTY))
4104 4131
#if !defined(HAVE_SETSID)
4105 4132
static rb_pid_t ruby_setsid(void);
......
6529 6556
    rb_define_module_function(rb_mProcess, "getpgid", proc_getpgid, 1);
6530 6557
    rb_define_module_function(rb_mProcess, "setpgid", proc_setpgid, 2);
6531 6558

  
6559
    rb_define_module_function(rb_mProcess, "getsid", proc_getsid, 1);
6532 6560
    rb_define_module_function(rb_mProcess, "setsid", proc_setsid, 0);
6533 6561

  
6534 6562
    rb_define_module_function(rb_mProcess, "getpriority", proc_getpriority, 2);
6535
-