From: Nobuyoshi Nakada Date: 2009-04-25T10:10:51+09:00 Subject: [ruby-core:23308] Re: [Bug #1403] Process.daemon should do a double fork to avoid problems with controlling terminals Hi, At Sat, 25 Apr 2009 09:52:46 +0900, Gary Wright wrote in [ruby-core:23307]: > >> Author: Gary Wright > >> Status: Open, Priority: Normal > >> ruby -v: ruby 1.9.0 (2008-07-25 revision 18217) [i686-darwin9] > >> > >> Standard practice when 'daemonizing' is to do a second fork > >> so that the final process is no longer a session leader and > >> therefore can't acquire a new controlling terminal. > > > > See Process.setsid. Process.daemon implies it. > > setsid is not sufficient. That makes the child process a session > leader, establishes a new process group, and breaks the association > with the controlling terminal, but it doesn't prevent the process from > acquiring a controlling terminal if it should happen to open a tty > device (generally on system V based systems, BSD systems are different). Then `i686-darwin9' is irrelevant at all? > The second fork ensures that the process (the grandchild of the > original process) is no longer a session leader and therefore can't > acquire a controlling terminal by opening a tty device. Could you show concrete example? -- Nobu Nakada