1

I'm using W32 GNU Emacs 24.1.50.1 with Cygwin bash 3.2.51. I know that this combination is very troublesome (see EmacsWiki and Cygwin list). However the problem I want to solve now is not confined to Cygwin. I got the issue with MinGW as well. So, the problem is:

In Emacs start a shell via M-x shell provided you have set up the variables shell-file-name and explicit-bash-args appropriately (see e.g. here). Then issue a command which expects stdin input, e.g. cat. To cancel out of cat you can usually type Ctrl-D once and you return to the shell prompt. In W32 emacs when you do this (or even when you issue explicitly M-x comint-send-eof) the cat command gets exited and the bash shell quits as well.

I tried to increases bash's "resilience' by setting the environment variable IGNOREEOF to, say, 5, but then a single Ctrl-D results in the following output

$ Use "exit" to leave the shell.
$ Use "exit" to leave the shell.
$ Use "exit" to leave the shell.
$ Use "exit" to leave the shell.
$ Use "exit" to leave the shell.
$ exit

Process shell finished

and, of course, the bash has exited again. This problem only happens when the shell runs in W32 emacs - Cygwin bash through the Cygwin tty window and MinGW bash through its own MinTTY work fine.

Why is this happening in W32 Emacs and how can I just exit the running subcommand (e.g. cat) when using W32 Emacs without exiting the bash shell?

Community
  • 1
  • 1
halloleo
  • 9,216
  • 13
  • 64
  • 122
  • I am ware that W32 Emacs doesn't support proper sifnal handling (that's why `M-x comint-stop-subjob` returns an error.) But W32 Emacs is doing *something* on `M-x comint-send-eof`. Unfortunate it's logic isn't expressed in ELISP, but burried in the C code I haven't examined yet. - So I am hoping a Emacs C-source guru could tell me more... – halloleo Oct 21 '12 at 02:48

3 Answers3

0

The notion of tty like you expect it to behave doesn't really exist in the W32 worl. If you want to see this Unixy behavior, you need not only to run a Cygwin program but that Cygwin program needs to talk to another Cygwin program (Emacs, terminal, you name it). IOW you'll only get that with the Cygwin version of Emacs.

Stefan
  • 27,908
  • 4
  • 53
  • 82
  • Full signal support I do get only with Cywin emacs, true. But W32 Emacs is doing *something* on `M-x comint-send-eof`, I would like to customise *that* behaviour. – halloleo Oct 21 '12 at 02:39
  • Then use `defadvice` on `comint-send-eof`. The default behavior is to call `process-send-eof` which on Windows (i.e. without pty) basically closes (one side of) the pipe. – Stefan Oct 21 '12 at 14:57
0

The GNU Emacs FAQ for MS Windows notes that this issue exists for any sub-process in the shell buffer. So it affects the DOS command line as well (but of course you don't usually use Ctrl-D in DOS, so it's not so noticeable). No workaround is suggested in the FAQ, so I'm guessing that there's no easy fix.

0

Usually you can use Ctrl-Z as well as Ctrl-D. Take a look at this note:

http://ignaciopp.wordpress.com/2009/07/02/emacs-shell-workaround-for-killing-input-in-windows-version/

Erik Knowles
  • 999
  • 7
  • 15