This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Calling RegisterServiceProcess from setsid ?


On Fri, Jun 06, 2003 at 07:46:46PM -0400, Pierre A. Humblet wrote:
>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.

I guess fhandler_tty_slave::close could call FreeConsole too when the
last tty is closed and setsid has been previously called.

I'll check in a change to do this.

cgf

Index: fhandler_tty.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_tty.cc,v
retrieving revision 1.96
diff -u -p -r1.96 fhandler_tty.cc
--- fhandler_tty.cc	20 Apr 2003 01:36:15 -0000	1.96
+++ fhandler_tty.cc	7 Jun 2003 15:10:39 -0000
@@ -583,7 +583,8 @@ fhandler_tty_slave::close ()
 {
   if (!output_done_event)
     {
-      fhandler_console::open_fhs--;
+      if (!--fhandler_console::open_fhs && myself->ctty == -1)
+	FreeConsole ();
       termios_printf ("decremented open_fhs %d", fhandler_console::open_fhs);
     }
   return fhandler_tty_common::close ();


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]