[uClibc]daemons terminating

Erik Andersen andersen at codepoet.org
Wed Oct 30 08:29:29 UTC 2002


On Tue Oct 29, 2002 at 08:37:35PM +0100, Bjorn Andersson wrote:
> I'm having problems with the daemon-function on a 48 Mhz motorola 860.
> It seems like parent process terminates before the child process has had 
> time
> to become session leader. Am I the only one with this problem?
> If a apply following patch everything works,

That sounds pretty wierd.  There should be no such race.
    <sound of Erik thinking>

Can you try this patch and let me know if it helps?

--- libc/unistd/daemon.c	11 Jan 2002 13:30:41 -0000	1.6
+++ libc/unistd/daemon.c	30 Oct 2002 08:27:53 -0000
@@ -48,6 +48,11 @@
 	if (setsid() == -1)
 		return(-1);
 
+	/* Make certain we are not a session leader, or else we
+	 * might reacquire a controlling terminal */
+	if (fork())
+		_exit(0);
+
 	if (!nochdir)
 		chdir("/");

 -Erik

--
Erik B. Andersen             http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--



More information about the uClibc mailing list