This is the mail archive of the cygwin@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: Brainstorming a fix for CTRL-C handling in an emacs shell buf fer (non-TTY)


I will certainly watch for your patch and give it a try.  I think the
root problem is:

.../d3.0$ echo $TERM
emacs
.../d3.0$ stty
stty: standard input: Not a character device

So unless you added code to work around the check for a tty in the
ctrl_c_handler, it's likely still to not work inside emacs.

Specifically, this expression causes the ctrl_c_handler to return TRUE
prematurely when tty_list's get_tty returns "nada":

    !t->getpgid () || t->getpgid () != myself->pid ||

I understand this is sometimes desirable, so didn't want to break
it for others who are running in a tty... thus I thought it'd be
good to make it an option.

Just for grins, I made an attempt at a patch that implements the same
type of fix I mentioned before as a CYGWIN=enable_nontty_ctrl_c option
(not married to that name really, I just pulled it out of the air).
Not sure if this is any more appealing.  Works equally well at fixing
the particular problem for emacs users though.

Your patch might very well fix it, in which case it's a moot point.
But here it is anyway in case the other fix doesn't do it.
I'll watch the Changelog for your up-coming patch.

Thanks for looking into this.  Troy


--- environ.cc-orig	Mon Apr 30 15:19:42 2001
+++ environ.cc	Fri May  4 14:27:36 2001
@@ -32,6 +32,7 @@
 extern BOOL allow_ntea;
 extern BOOL allow_smbntsec;
 extern BOOL allow_winsymlinks;
+extern BOOL allow_nontty_ctrl_c;  /* used in ctrl_c_handler in
exceptions.cc */
 extern BOOL strip_title_path;
 extern int pcheck_case;
 extern DWORD chunksize;
@@ -500,6 +501,7 @@
   {"title", {&display_title}, justset, NULL, {{FALSE}, {TRUE}}},
   {"tty", {NULL}, set_process_state, NULL, {{0}, {PID_USETTY}}},
   {"winsymlinks", {&allow_winsymlinks}, justset, NULL, {{FALSE}, {TRUE}}},
+  {"enable_nontty_ctrl_c", {&allow_nontty_ctrl_c}, justset, NULL, {{FALSE},
{TRUE}}},
   {NULL, {0}, justset, 0, {{0}, {0}}}
 };
 
--- exceptions.cc-orig	Sun Apr 29 21:09:18 2001
+++ exceptions.cc	Fri May  4 14:07:57 2001
@@ -26,6 +26,13 @@
 
 char debugger_command[2 * MAX_PATH + 20];
 
+/* Enables handling of CTRL-C (SIGINT) for processes even if they do not
+ * have a tty on stdin.  Most notably, NTEmacs (native win32) looks like
+ * a non-character device from cygwin's perspective.  This allows CTRL-C
+ * to be handled in BASH when running in an NTEmacs shell buffer.
+ */
+int allow_nontty_ctrl_c = FALSE;
+
 extern "C" {
 static int handle_exceptions (EXCEPTION_RECORD *, void *, CONTEXT *, void
*);
 extern void sigreturn ();
@@ -892,8 +899,9 @@
   tty_min *t = cygwin_shared->tty.get_tty (myself->ctty);
   /* Ignore this if we're not the process group lead since it should be
handled
      *by* the process group leader. */
-  if (!t->getpgid () || t->getpgid () != myself->pid ||
-      (GetTickCount () - t->last_ctrl_c) < MIN_CTRL_C_SLOP)
+  if ((GetTickCount () - t->last_ctrl_c) < MIN_CTRL_C_SLOP ||
+      (!allow_nontty_ctrl_c &&
+       (!t->getpgid () || t->getpgid () != myself->pid)))
     return TRUE;
   else
     /* Otherwise we just send a SIGINT to the process group and return TRUE
(to indicate


-----Original Message-----
From: Christopher Faylor [mailto:cgf@redhat.com]
Sent: Friday, May 04, 2001 2:42 PM
To: 'cygwin@cygwin.com'
Subject: Re: Brainstorming a fix for CTRL-C handling in an emacs shell
buf fer (non-TTY)


On Fri, May 04, 2001 at 01:25:36PM -0600, Troy Noble wrote:
>Is that patch in the latest sources?

Yes.  That is what I meant when I said "I've checked in a fix." Btw, you
can answer this question by looking at the ChangeLog.

I appreciate your tracking this down further but I don't see any reason
to add a special environment variable.  I will check in another change
in the next hour or so.  If you could check this out and see if it
fixes your problem, I would appreciate it.

cgf

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


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