[ANNOUNCEMENT] Update: mintty 2.1.2

Thomas Wolff towo@towo.net
Fri Jul 24 22:03:00 GMT 2015


Am 24.07.2015 um 15:18 schrieb Houder:
> 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?
Thomas

--
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



More information about the Cygwin mailing list