* process.c (ruby_setsid): split from proc_setsid.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
893c123bfb
commit
4dcaa9e5aa
@ -1,4 +1,6 @@
|
|||||||
Fri Apr 2 08:22:51 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Apr 2 08:24:56 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* process.c (ruby_setsid): split from proc_setsid.
|
||||||
|
|
||||||
* process.c (proc_daemon): use EXIT_SUCCESS instead of magic number.
|
* process.c (proc_daemon): use EXIT_SUCCESS instead of magic number.
|
||||||
|
|
||||||
|
22
process.c
22
process.c
@ -3389,6 +3389,10 @@ proc_setpgid(VALUE obj, VALUE pid, VALUE pgrp)
|
|||||||
|
|
||||||
|
|
||||||
#if defined(HAVE_SETSID) || (defined(HAVE_SETPGRP) && defined(TIOCNOTTY))
|
#if defined(HAVE_SETSID) || (defined(HAVE_SETPGRP) && defined(TIOCNOTTY))
|
||||||
|
#if !defined(HAVE_SETSID)
|
||||||
|
static rb_pid_t ruby_setsid(void);
|
||||||
|
#define setsid() ruby_setsid()
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Process.setsid => fixnum
|
* Process.setsid => fixnum
|
||||||
@ -3403,18 +3407,22 @@ proc_setpgid(VALUE obj, VALUE pid, VALUE pgrp)
|
|||||||
static VALUE
|
static VALUE
|
||||||
proc_setsid(void)
|
proc_setsid(void)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_SETSID)
|
|
||||||
rb_pid_t pid;
|
rb_pid_t pid;
|
||||||
|
|
||||||
rb_secure(2);
|
rb_secure(2);
|
||||||
pid = setsid();
|
pid = setsid();
|
||||||
if (pid < 0) rb_sys_fail(0);
|
if (pid < 0) rb_sys_fail(0);
|
||||||
return PIDT2NUM(pid);
|
return PIDT2NUM(pid);
|
||||||
#elif defined(HAVE_SETPGRP) && defined(TIOCNOTTY)
|
}
|
||||||
|
|
||||||
|
#if !defined(HAVE_SETSID)
|
||||||
|
#define HAVE_SETSID 1
|
||||||
|
static rb_pid_t
|
||||||
|
ruby_setsid(void)
|
||||||
|
{
|
||||||
rb_pid_t pid;
|
rb_pid_t pid;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
rb_secure(2);
|
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
#if defined(SETPGRP_VOID)
|
#if defined(SETPGRP_VOID)
|
||||||
ret = setpgrp();
|
ret = setpgrp();
|
||||||
@ -3424,15 +3432,15 @@ proc_setsid(void)
|
|||||||
#else
|
#else
|
||||||
ret = setpgrp(0, pid);
|
ret = setpgrp(0, pid);
|
||||||
#endif
|
#endif
|
||||||
if (ret == -1) rb_sys_fail(0);
|
if (ret == -1) return -1;
|
||||||
|
|
||||||
if ((fd = open("/dev/tty", O_RDWR)) >= 0) {
|
if ((fd = open("/dev/tty", O_RDWR)) >= 0) {
|
||||||
ioctl(fd, TIOCNOTTY, NULL);
|
ioctl(fd, TIOCNOTTY, NULL);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
return PIDT2NUM(pid);
|
return pid;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#define proc_setsid rb_f_notimplement
|
#define proc_setsid rb_f_notimplement
|
||||||
#endif
|
#endif
|
||||||
@ -4531,7 +4539,7 @@ proc_setmaxgroups(VALUE obj, VALUE val)
|
|||||||
return INT2FIX(maxgroups);
|
return INT2FIX(maxgroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_DAEMON) || defined(HAVE_FORK)
|
#if defined(HAVE_DAEMON) || (defined(HAVE_FORK) && defined(HAVE_SETSID))
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* Process.daemon() => 0
|
* Process.daemon() => 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user