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?