>> Hi Thomas, >>> Maybe setsid() should not be called if fork() fails... >>> Could you try this please: >>> if (daemonize && !isatty(0)) { >>> int pid = fork(); >>> if (pid > 0) exit(0); // exit parent process >>> if (pid == 0) setsid(); // detach child process >>> if (pid < 0) { >>> error("could not detach from caller"); >>> exit(9); >>> } >>> } >> Hint: source code of setsid.c -- util-linux package) > ... or maybe the parent thread should not exit immediately but wait: > if (daemonize && !isatty(0)) { > #include <sys/wait.h> > int status; > int pid = fork(); > if (pid > 0) { > waitpid(pid, &status, 0); > exit(0); > } > setsid(); > } > > Can you please try both alternatives?
Hi Thomas, I found the bug (more or less): it is me (AND you). More will follow soon. Henri -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple