This is the mail archive of the cygwin-patches@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]

Re: console popping up unnecessarily in xterm (cygwin 1.3.3)


>>> On 05 Oct 2001 23:21:20 +0900
>>> Kazuhiro Fujieda <fujieda@jaist.ac.jp> said:

> The same logic should also solve it on xterm. I guess another
> bug disturbs it. As you may know, Cygwin DLL 1.3.3 has a bug
> related to the inheritance of file descriptors in fork. It is
> fixed in the recent development snapshots.

I'm sorry. I found the logic was insufficient to solve the
problem on xterm. The following patch should solve it.
I feel these changes are cheap tricks. I'll make a radical
cure in the near future.

2001-10-06  Kazuhiro Fujieda  <fujieda@jaist.ac.jp>

	* winsup.h: Declare check_pty_fds.
	* syscalls.cc (check_pty_fds): Renamed from check_ttys_fds. Also
	check pty master.
	(setsid): Use check_pty_fds.
	* dtable.cc (dtable::dec_console_fds): Add check on pty fds.

Index: dtable.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/dtable.cc,v
retrieving revision 1.57
diff -u -p -r1.57 dtable.cc
--- dtable.cc	2001/10/03 03:49:26	1.57
+++ dtable.cc	2001/10/05 18:38:36
@@ -55,7 +55,8 @@ set_std_handle (int fd)
 void
 dtable::dec_console_fds ()
 {
-  if (console_fds > 0 && !--console_fds && myself->ctty != TTY_CONSOLE)
+  if (console_fds > 0 && !--console_fds &&
+      myself->ctty != TTY_CONSOLE && !check_pty_fds())
     FreeConsole ();
 }
 
Index: syscalls.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/syscalls.cc,v
retrieving revision 1.155
diff -u -p -r1.155 syscalls.cc
--- syscalls.cc	2001/10/05 04:21:41	1.155
+++ syscalls.cc	2001/10/05 18:38:36
@@ -65,19 +65,20 @@ close_all_files (void)
   cygwin_shared->delqueue.process_queue ();
 }
 
-static BOOL __stdcall
-check_ttys_fds (void)
+BOOL __stdcall
+check_pty_fds (void)
 {
   int res = FALSE;
-  SetResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "close_all_files");
+  SetResourceLock (LOCK_FD_LIST, WRITE_LOCK, "check_pty_fds");
   fhandler_base *fh;
   for (int i = 0; i < (int) cygheap->fdtab.size; i++)
-    if ((fh = cygheap->fdtab[i]) != NULL && fh->get_device() == FH_TTYS)
+    if ((fh = cygheap->fdtab[i]) != NULL &&
+	(fh->get_device() == FH_TTYS || fh->get_device() == FH_PTYM))
       {
 	res = TRUE;
 	break;
       }
-  ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK | READ_LOCK, "close_all_files");
+  ReleaseResourceLock (LOCK_FD_LIST, WRITE_LOCK, "check_pty_fds");
   return res;
 }
 
@@ -270,7 +271,7 @@ setsid (void)
     {
       if (myself->ctty == TTY_CONSOLE &&
 	  !cygheap->fdtab.has_console_fds () &&
-	  !check_ttys_fds ())
+	  !check_pty_fds ())
 	FreeConsole ();
       myself->ctty = -1;
       myself->sid = _getpid ();
Index: winsup.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/winsup.h,v
retrieving revision 1.70
diff -u -p -r1.70 winsup.h
--- winsup.h	2001/10/05 00:17:57	1.70
+++ winsup.h	2001/10/05 18:38:36
@@ -144,6 +144,7 @@ void events_init (void);
 void events_terminate (void);
 
 void __stdcall close_all_files (void);
+BOOL __stdcall check_pty_fds (void);
 
 /* Invisible window initialization/termination. */
 HWND __stdcall gethwnd (void);

____
  | AIST      Kazuhiro Fujieda <fujieda@jaist.ac.jp>
  | HOKURIKU  Center for Information Science
o_/ 1990      Japan Advanced Institute of Science and Technology


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