This is the mail archive of the
mailing list for the Cygwin project.
Re: setsid() does not call FreeConsole() even if all files are closed
- From: Christopher Faylor <cgf-no-personal-reply-please at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Sun, 13 Nov 2005 13:14:22 -0500
- Subject: Re: setsid() does not call FreeConsole() even if all files are closed
- References: <4377651F.email@example.com>
- Reply-to: cygwin at cygwin dot com
On Sun, Nov 13, 2005 at 05:09:03PM +0100, Christian Franke wrote:
>when starting a daemon from the console, the console will not close
>before the daemon finishes.
>Shell exits, but console window persists until syslogd is terminated.
>+ #ifdef __CYGWIN__
>The attached program demonstrates the issue.
The attached program demonstrates the assumption that only
stdin/stdout/stderr are open when the program is started. A shell could
conceivably keep other fds open.
Try applying the below patch to gain the behavior that you want.
--- testsetsid.cc.orig 2005-11-13 12:34:28.000000000 -0500
+++ testsetsid.cc 2005-11-13 13:10:30.000000000 -0500
@@ -6,8 +6,10 @@ main(int argc, char **argv)
+ int nfds = getdtablesize ();
- fclose(stdin); fclose(stdout); fclose(stderr);
+ for (int i = 0; i < nfds; i++)
+ close (i);
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html