This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
Re: console popping up unnecessarily in xterm (cygwin 1.3.3)
- To: cygwin-patches at cygwin dot com
- Subject: Re: console popping up unnecessarily in xterm (cygwin 1.3.3)
- From: Christopher Faylor <cgf at redhat dot com>
- Date: Fri, 5 Oct 2001 15:04:33 -0400
- References: <Liam.1001728633.534708.15417.245609177@mergioo> <s1sn136np5r.fsf@jaist.ac.jp> <s1s4rpd9ard.fsf@jaist.ac.jp>
- Reply-To: cygwin-patches at cygwin dot com
On Sat, Oct 06, 2001 at 03:56:06AM +0900, Kazuhiro Fujieda wrote:
>>>> 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.
Hmm. I'm not sure that I understand the logic here. I understand why
this would cure the problem with xterm since it uses a pty, but you're
now saying that if a process is using ptys it should not free its
console. That seems sort of arbitrary.
I know that you know this. I'm just stating it "out loud".
Of course, having said it out loud, I have no idea how to fix this any
other way, either.
I'll probably end up checking this in but I'd like to think about it a
little first. Please bug me in a couple of days if it seems like I've
forgotten about it.
cgf
>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
--
cgf@cygnus.com Red Hat, Inc.
http://sources.redhat.com/ http://www.redhat.com/