зеркало из https://github.com/github/ruby.git
Ignore EPERM which means already being process-leader
This commit is contained in:
Родитель
b4546d26f2
Коммит
55e540f7ab
|
@ -7115,7 +7115,8 @@ rb_daemon(int nochdir, int noclose)
|
|||
default: _exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (setsid() < 0) return -1;
|
||||
/* ignore EPERM which means already being process-leader */
|
||||
if (setsid() < 0) (void)0;
|
||||
|
||||
if (!nochdir)
|
||||
err = chdir("/");
|
||||
|
|
|
@ -1881,17 +1881,19 @@ class TestProcess < Test::Unit::TestCase
|
|||
if f
|
||||
assert_equal(f.pid, Process.wait(f.pid))
|
||||
|
||||
dpid, ppid = Integer(f.gets), Integer(f.gets)
|
||||
dpid, ppid, dsid = 3.times.map {Integer(f.gets)}
|
||||
|
||||
message = "daemon #{dpid} should be detached"
|
||||
assert_not_equal($$, ppid, message) # would be 1 almost always
|
||||
assert_raise(Errno::ECHILD, message) {Process.wait(dpid)}
|
||||
assert_kind_of(Integer, Process.kill(0, dpid), message)
|
||||
assert_equal(dpid, dsid)
|
||||
|
||||
break # close f, and let the daemon resume and exit
|
||||
end
|
||||
Process.setsid rescue nil
|
||||
Process.daemon(false, true)
|
||||
puts $$, Process.ppid
|
||||
puts $$, Process.ppid, Process.getsid
|
||||
$stdin.gets # wait for the above assertions using signals
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче