setsid() does not call FreeConsole() even if all files are closed
Igor Pechtchanski
pechtcha@cs.nyu.edu
Sun Nov 13 23:54:00 GMT 2005
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/
More information about the Cygwin
mailing list