From cdce1dd4efc2ee6bf8f1b0186aa9be755a5bfa89 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 1 May 2013 03:14:55 +0000 Subject: [PATCH] process.c: rb_daemon should not raise * process.c (rb_daemon): should not raise exceptions, since proc_daemon() will deal with errors. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- process.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/process.c b/process.c index c608721713..753e27ec09 100644 --- a/process.c +++ b/process.c @@ -5676,26 +5676,19 @@ rb_daemon(int nochdir, int noclose) #else int n; - switch (rb_fork_ruby(NULL)) { - case -1: - rb_sys_fail("daemon"); - case 0: - break; - default: - _exit(EXIT_SUCCESS); +#define fork_daemon() \ + switch (rb_fork_ruby(NULL)) { \ + case -1: return -1; \ + case 0: break; \ + default: _exit(EXIT_SUCCESS); \ } - proc_setsid(); + fork_daemon(); + + if (setsid() < 0) return -1; /* must not be process-leader */ - switch (rb_fork_ruby(NULL)) { - case -1: - return -1; - case 0: - break; - default: - _exit(EXIT_SUCCESS); - } + fork_daemon(); if (!nochdir) err = chdir("/");