Skip to content
This repository has been archived by the owner. It is now read-only.

Fix _UnixWritePipeTransport to support TTY #147

Closed
GoogleCodeExporter opened this issue Apr 10, 2015 · 2 comments
Closed

Fix _UnixWritePipeTransport to support TTY #147

GoogleCodeExporter opened this issue Apr 10, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

@GoogleCodeExporter GoogleCodeExporter commented Apr 10, 2015

_UnixWritePipeTransport currently listen to read availibity to be notified when 
the pipe is closed. The problem with TTY is that writing something into a TTY 
makes immediatly these data available to read. Said differently, the read and 
the write end of the pipe are the same. For example, for stdin and stdout, 
os.path.samestat(os.fstat(0), os.fstat(1)) is True.

The following patch modifies _UnixWritePipeTransport to not listen for read 
event if the pipe is a TTY:
http://codereview.appspot.com/66190043

It adds a dummy example copying stdin into stdout, line by line. I tested it 
with TTY, when stdin is a pipe, and when stdout is a pipe. Use CTRL+d to quit, 
as the UNIX cat command.

Original issue reported on code.google.com by victor.s...@gmail.com on 19 Feb 2014 at 9:51

@GoogleCodeExporter
Copy link
Author

@GoogleCodeExporter GoogleCodeExporter commented Apr 10, 2015

An interesting observation about nonblocking mode for a pty:

> The problem with O_NONBLOCK is that it's too heavy: it hits an entire ofile, 
not just an fd. For example, suppose I set O_NONBLOCK on a pty on stdout, and 
another program has the same stdout. That other program then has O_NONBLOCK set 
too. Many programs can't handle O_NONBLOCK and will break horribly in this 
situation. http://cr.yp.to/unix/nonblock.html

I don't know whether it explains why `cat` breaks in your example.

Original comment by isidore....@gmail.com on 5 May 2014 at 4:40

@GoogleCodeExporter
Copy link
Author

@GoogleCodeExporter GoogleCodeExporter commented Apr 10, 2015

I'm not sure that it's possible to handle TTY with a simple file descriptor. 
Since my change doesn't work and I'm not interested to support TTY, I abandon 
this change.

Don't hesitate to write a new patch and open a new issue if you are intersted 
to support TTY.

Original comment by victor.s...@gmail.com on 9 Jan 2015 at 2:30

  • Changed state: WontFix
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.