[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ^D is broken in shell-mode
From: |
David De La Harpe Golden |
Subject: |
Re: ^D is broken in shell-mode |
Date: |
Wed, 09 Jun 2010 01:05:58 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100515 Icedove/3.0.4 |
On 08/06/10 21:22, Stefan Monnier wrote:
It now results in a literal ^D being seen by the subproces.
I vaguely recall seeing recently that emacs stopped using ICANON mode
for ptys; I presume this is the cause?
Yes.
It's been a long time since I did pty programming, but I seem to recall
that at least in some pty states, doing a zero-length write in the pty
master will send an end-of-file to the slave tty. I don't recall the
details though...
FWIW, The write(3) manpage has this to say (about pipes not ptys):
> Also, some existing systems (for example, Eighth Edition)
> permit a write of zero bytes to mean that the reader should get an
> end-of-file indication; for those systems, a return value of zero
> from write() indicates a successful write of an end-of-file
> indication.
That's possibly what Miles is recollecting?
I'm not sure it works for ptys, or that it's actually TRT here...
I really wish someone could help.
Not necessarily helping:
If you turn off ICANON, it's little wonder EOF char is just
passed through?
This page here:
http://www.lafn.org/~dave/linux/terminalIO.html
makes the claim:
"""
Cooked mode is the default state of your terminal for almost all shells.
At least when you execute another program with the shell, the terminal
is put into cooked mode before it makes a call to an exec function.
"""
Stty in shell exec'd processes and shell children do indeed show a
cooked terminal on my system, so likely emacs when in its capacity as a
"normal" shell / superior process should be ensuring the pty slave it
hands to children is ICANON out-of-box?
But n.b. that means the MAX_INPUT/MAX_CANON limits described at that
link would apply.