From 331ce20e8e9e1d4f26cd8202eff2418ab80cb879 Mon Sep 17 00:00:00 2001 From: yugui Date: Mon, 4 May 2009 12:31:33 +0000 Subject: 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 --- process.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'process.c') 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("/"); -- cgit v1.2.3