summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-04 12:31:33 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-05-04 12:31:33 +0000
commit331ce20e8e9e1d4f26cd8202eff2418ab80cb879 (patch)
tree50b2c59e65ced47367cb333f54264cea095fc72d
parent18d1ea6cc83ee236f9d8368fa5cb68af839f03e8 (diff)
merges r23277 and r23280 from trunk into ruby_1_9_1.
-- * 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] -- * 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:23305] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@23343 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 105ad336f9..ac7595e4f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat Apr 25 19:11:13 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:23305]
+
Sun Apr 19 14:43:18 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (ruby_cleanup): the order of local variables on stack is
diff --git a/configure.in b/configure.in
index 5ddea5d41f..3b79bec801 100644
--- a/configure.in
+++ b/configure.in
@@ -518,6 +518,14 @@ AC_ARG_ENABLE(pthread,
dnl Checks for libraries.
case "$target_os" in
+*bsd*|dragonfly*)
+ ;;
+*)
+ ac_cv_func_daemon=no
+ ;;
+esac
+
+case "$target_os" in
nextstep*) ;;
openstep*) ;;
rhapsody*) ;;
@@ -531,7 +539,6 @@ darwin*) LIBS="-lobjc $LIBS"
],
[
ac_cv_header_ucontext_h=no
- ac_cv_func_daemon=no
],
[
AC_DEFINE(BROKEN_SETREUID, 1)
diff --git a/process.c b/process.c
index 834520b608..6e704f6056 100644
--- a/process.c
+++ b/process.c
@@ -4216,7 +4216,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:
@@ -4225,6 +4225,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("/");