[PATCH] Cygwin: pty: Disable clear screen for ssh sessions with -t option.

Michael Haubenwallner michael.haubenwallner@ssi-schaefer.com
Tue Oct 22 10:06:00 GMT 2019


On 10/22/19 10:04 AM, Corinna Vinschen wrote:
> On Oct 22 09:20, Michael Haubenwallner wrote:
>> On 10/18/19 1:37 PM, Takashi Yano wrote:

>>> +      const char *term = getenv ("TERM");
>>> +      if (term && strcmp (term, "dumb") && !strstr (term, "emacs") &&
>>> +	  wcsstr (myself->progname, L"\\usr\\sbin\\sshd.exe"))

>> Again, my real problem does not utilize ssh at all, but is some python script
>> using multiple pty.openpty() to spawn commands inside, to allow for herding
>> all the subprocesses started by the commands (Ctrl-C or similar).

> In terms of clearing the screen at all, what's your opinion, Michael?

While I do not fully understand TTY handling, clearing the screen because
just opening a PTY doesn't feel correct.

To start with, attached is some python script where I do not expect to see
the initial clear screen code, but the one from /usr/bin/clear only.

This is what I see with python3 on *Linux*:

$ TERM=dumb python3 ./ptytest1.py 
select read: [3] except: []
read: b'/home/haubi\r\n'
select read: [3] except: []
quit: [Errno 5] Input/output error

$ TERM=xterm python3 ./ptytest1.py 
select read: [3] except: []
read: b'/home/haubi\r\n'
select read: [3] except: []
read: b'\x1b[H\x1b[2J\x1b[3J'
select read: [3] except: []
quit: [Errno 5] Input/output error

$ TERM=screen python3 ./ptytest1.py 
select read: [3] except: []
read: b'/home/haubi\r\n'
select read: [3] except: []
read: b'\x1b[H\x1b[J'
select read: [3] except: []
quit: [Errno 5] Input/output error

Note that the clear screen code does depend on the TERM value, and /usr/bin/clear
does even yell if TERM is empty, unknown or unset.

Also note that Linux select() does not yield the fd as exception when it was closed.

Interesting enough, cygwin-3.0.7 does dump core somewhere in between, so the real
python program probably does some additional setup I've not extracted yet.

/haubi/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ptytest1.py
Type: text/x-python
Size: 602 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20191022/968a4693/attachment.py>


More information about the Cygwin-patches mailing list