This is the mail archive of the
cygwin-developers@cygwin.com
mailing list for the Cygwin project.
Re: Calling RegisterServiceProcess from setsid ?
I think I have figured out most of what's happening in what
I reported on Wednesday.
<http://cygwin.com/ml/cygwin-developers/2003-06/msg00037.html>
The outcomes depend on the way the program is written because
of a Cygwin feature (don't know if design or accident).
-exim closes 0/1/2 then setsids
-sshd setsids then closes 0/1/2 (actually sets them to /dev/null)
-inetd sets 0 to /dev/null, setsids, then closes 0/1/2
-cron setsids but doesn't close anything (that's why
Ronald Landheer-Cieslak is reporting problem on the list)
Programs that close 0/1/2 and setsid (in any order) always survive
log offs, whether started from cygwin.bat or from rxvt.
Programs that setsid and then close 0/1/2 do survive log offs when
started from cygwin.bat, but not from rxvt.
I think the last two observations come from the facts that
setsid calls FreeConsole when fhandler_console::open_fhs == 0; it also
sets myself->ctty to -1.
fhandler_console::close calls FreeConsole when fhandler_console::open_fhs
becomes 0, and myself->ctty != TTY_CONSOLE (e.g. when called after setsid).
However fhandler_tty_slave::close never calls FreeConsole, even when
it is called after setsid and fhandler_console::open_fhs becomes 0.
I don't know if it's by design, but it surely makes a difference.
The only effect (I can see) of RegisterServiceProcess is to remove
the program from the "Close Program", a.k.a. Ctrl-Alt-Del pop-up.
It has apparently nothing to do with surviving log offs, it's mostly
a waste of effort (except for Trojans, viruses and worms) :(
I know this may sound crazy but I have checked on 95/98/ME.
Pierre