emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ^D is broken in shell-mode


From: Jan Djärv
Subject: Re: ^D is broken in shell-mode
Date: Wed, 09 Jun 2010 08:28:23 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4

2010-06-08 22:22, Stefan Monnier skrev:
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...

I really wish someone could help.  At least if someone could point me to
some kind of documentation that would be very helpful.  The best "doc"
I could find so far is the xterm source code, which I do not really
understand and whose behavior I haven't been able to reproduce yet
(e.g. it seems not to disable ICANON mode, and it doesn't seem to ever
send EOF either, even when sending large chunks of data, yet that data
doesn't get truncated, whereas when I try to to make Emacs send large
amounts of data in ICANON mode without EOFs, it gets truncated).


I don't know what the original problem was (sending large amount of data may hang?) that prompted the removal of ICANON. But as far as xterm goes (if it hasn't changed radically in the last year or so), it does something like this:

loop1:
try to write min(128 characters, what we want to write) to the pty (128 is half of what POSIX says is the minimum pty buffer size)

If write returned what we put in and there is more to write, goto loop1.

If write returned less or (-1 and errno is EAGAIN/EWOULDBLOCK), stop writing and select on the fd for write.

When select says it is OK to write again, start at loop1.

        Jan D.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]