This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ANNOUNCEMENT] Update: mintty 2.1.2


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]