This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: setsid() does not call FreeConsole() even if all files are closed
- From: Igor Pechtchanski <pechtcha at cs dot nyu dot edu>
- To: Christian Franke <Christian dot Franke at t-online dot de>
- Cc: cygwin at cygwin dot com
- Date: Sun, 13 Nov 2005 16:06:23 -0500 (EST)
- Subject: Re: setsid() does not call FreeConsole() even if all files are closed
- References: <4377651F.9050400@t-online.de>
- Reply-to: cygwin at cygwin dot com
On Sun, 13 Nov 2005, Christian Franke wrote:
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
According to syscall.cc:setsid(), FreeConsole() should be called if a
tty exists and no files are open.
Yep, so, as CGF noted, try
$ /usr/sbin/syslogd >/dev/null 2>&1 </dev/null
$ exit
However, the main question is whether syslogd *should* close the file
descriptors if it doesn't intend to write to them. I'm not familiar
enough with syslogd's operation -- if it normally writes to stdout/stderr
(or reads from stdin), the above is the only way to get the shell to
close. If syslogd never reads/writes to standard filehandles in daemon
mode, it should close them itself (i.e., this is a syslogd bug).
Igor
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ pechtcha@cs.nyu.edu
ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D.
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
If there's any real truth it's that the entire multidimensional infinity
of the Universe is almost certainly being run by a bunch of maniacs. /DA
--
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/