aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-04-25 09:21:49 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-04-25 09:21:49 +0000
commit9bb7a8ccddf15537da6af71e594322f2519350f7 (patch)
treeb3baff1e29bd6f902d015ba08e50e60fc6c2cccd
parent0dae2c910fa646a2b41d33f0b4d1dad818eb00da (diff)
downloadruby-9bb7a8ccddf15537da6af71e594322f2519350f7.tar.gz
* configure.in (ac_cv_func_daemon): use daemon(3) only on *BSD.
* process.c (proc_daemon): double fork to ensure not having ctty. [ruby-core:23311] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--configure.in9
-rw-r--r--process.c12
3 files changed, 26 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index ebf58e9919..3ed1d8f5d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat Apr 25 18:21:47 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * configure.in (ac_cv_func_daemon): use daemon(3) only on *BSD.
+
+ * process.c (proc_daemon): double fork to ensure not having ctty.
+ [ruby-core:23311]
+
Sat Apr 25 16:19:48 2009 Tanaka Akira <akr@fsij.org>
* time.c (month_arg): extracted from time_arg.
diff --git a/configure.in b/configure.in
index 127901f80a..fe99222ba4 100644
--- a/configure.in
+++ b/configure.in
@@ -728,6 +728,14 @@ AC_ARG_ENABLE(pthread,
dnl Checks for libraries.
case "$target_os" in
+when(*bsd*|dragonfly*)
+ ;;
+when(*)
+ ac_cv_func_daemon=no
+ ;;
+esac
+
+case "$target_os" in
when(nextstep*) ;;
when(openstep*) ;;
when(rhapsody*) ;;
@@ -744,7 +752,6 @@ when(darwin*) RUBY_PREPEND_OPTION(LIBS, -lobjc)
AC_MSG_RESULT($macosx_10_5)
if test $macosx_10_5 = yes; then
ac_cv_header_ucontext_h=no
- ac_cv_func_daemon=no
else
AC_DEFINE(BROKEN_SETREUID, 1)
AC_DEFINE(BROKEN_SETREGID, 1)
diff --git a/process.c b/process.c
index 5669cf6641..4aeb615e73 100644
--- a/process.c
+++ b/process.c
@@ -4545,7 +4545,7 @@ proc_daemon(int argc, VALUE *argv)
#elif defined(HAVE_FORK)
switch (rb_fork(0, 0, 0, Qnil)) {
case -1:
- return (-1);
+ return INT2FIX(-1);
case 0:
break;
default:
@@ -4554,6 +4554,16 @@ proc_daemon(int argc, VALUE *argv)
proc_setsid();
+ /* must not be process-leader */
+ switch (rb_fork(0, 0, 0, Qnil)) {
+ case -1:
+ return INT2FIX(-1);
+ case 0:
+ break;
+ default:
+ _exit(0);
+ }
+
if (!RTEST(nochdir))
(void)chdir("/");