setsid() does not call FreeConsole() even if all files are closed

Christian Franke Christian.Franke@t-online.de
Sun Nov 13 16:46:00 GMT 2005


Hi,

when starting a daemon from the console, the console will not close 
before the daemon finishes.

Try, e.g:

$ /usr/sbin/syslogd
$ exit

Shell exits, but console window persists until syslogd is terminated.

Workaround:

   setsid();
+  #ifdef __CYGWIN__
+  FreeConsole();
+  #endif


The attached program demonstrates the issue.

If run without an argument, the output line is written to current console.
It should be written to a new console, but AllocConsole() does nothing 
because the current console is still attached.

If run with any argument, FreeConsole is called after setsid().
It should return FALSE, but returns TRUE (status=1).
Then the output line is written to a new console.

According to syscall.cc:setsid(), FreeConsole() should be called if a 
tty exists and no files are open.

Diagnostic via strace doesn't help. The program works as expected if run 
via strace ... interesting?-)

Thanks for any help

Christian

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: testsetsid.cc
URL: <http://cygwin.com/pipermail/cygwin/attachments/20051113/7cb32003/attachment.cc>
-------------- next part --------------
--
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/


More information about the Cygwin mailing list