diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-01-30 11:46:03 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-01-30 11:46:03 +0000 |
commit | 1bd12d78c79c1194363f7755acab0a31109b935a (patch) | |
tree | 47987bcdbca56b2e8f1669e304e215d2d927e04b /process.c | |
parent | edd9ca9cd2760fd50ca9a51477b36e887510f476 (diff) |
merge revision(s) 40534,41886,41903,41910: [Backport #8616]
process.c: rb_daemon should not raise
* process.c (rb_daemon): should not raise exceptions, since
proc_daemon() will deal with errors.
* process.c (fork_daemon): kill the other threads all and abandon the
kept mutexes.
* process.c (fork_daemon): kill the other threads all and abandon the
kept mutexes.
* process.c (rb_daemon): daemon(3) is implemented with fork(2).
Therefore it needs rb_thread_atfork(). (and revert r41903)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@44766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 25 |
1 files changed, 9 insertions, 16 deletions
@@ -4918,26 +4918,19 @@ rb_daemon(int nochdir, int noclose) #else int n; - switch (rb_fork(0, 0, 0, Qnil)) { - case -1: - rb_sys_fail("daemon"); - case 0: - break; - default: - _exit(EXIT_SUCCESS); +#define fork_daemon() \ + switch (rb_fork(0, 0, 0, Qnil)) { \ + 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(0, 0, 0, Qnil)) { - case -1: - return -1; - case 0: - break; - default: - _exit(EXIT_SUCCESS); - } + fork_daemon(); if (!nochdir) err = chdir("/"); |