Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Date: Tue, 10 Feb 2004 10:30:18 -0600
From: roywestfall@houston.rr.com
Subject: Recently changed behavior for daemons
To: cygwin@cygwin.com
Cc: roywestfall@houston.rr.com
Reply-to: roywestfall@houston.rr.com
Message-id: <175d2217261e.17261e175d22@texas.rr.com>
MIME-version: 1.0
Content-type: text/plain; charset=us-ascii
Content-language: en
Content-transfer-encoding: 7BIT
Content-disposition: inline
X-Virus-Scanned: Symantec AntiVirus Scan Engine
Note-from-DJ: This may be spam

I recently upgraded to version 1.5.7-1

Since then, when I run a daemon (i.e. a program that forks, closes file descriptors, chdirs to /, and calls setsid) from a cygwin (non-X) command shell, I am unable to close the cygwin window.  I've tried doing the standard daemon things, and calling the daemon() function, both behave the same.

Below is some sample code to demonstrate, using either method, pass any command line argument to call daemon().

This program simply sleeps for 2 minutes then exits.  If I run it, then exit bash, my window doesn't close.  Forcing the window to close terminates the program.

This behavior has changed since the upgrade.

Roy Westfall
roywestfall<AT>houston<DOT>rr<DOT>com

#include <unistd.h>
#include <fcntl.h>

int main(int ac, char* av[])
{
  int i = 0;

  if (ac > 1)
  {
      daemon(0,0);
  }
  else
  {
    if (fork())
      return 0;
    for (i = getdtablesize()-1; i >= 0; i--)
      close(i);
    open("/dev/null",O_RDONLY);
    dup(open("/dev/null",O_WRONLY));
    chdir("/");
    setsid();
  }

  sleep(120);

  return 0;
}



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

