[issue41494] Add window resizing support [ SIGWINCH ] to Lib/pty

2020-08-07 Thread Soumendra Ganguly


Soumendra Ganguly  added the comment:

Updated diff.

Changes _ekill()

--
Added file: https://bugs.python.org/file49376/pty.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41494] Add window resizing support [ SIGWINCH ] to Lib/pty

2020-08-06 Thread Soumendra Ganguly


Change by Soumendra Ganguly :


--
pull_requests: +20896
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/21752

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41494] Add window resizing support [ SIGWINCH ] to Lib/pty

2020-08-06 Thread Soumendra Ganguly


New submission from Soumendra Ganguly :

This was tested using Python 3.7 after commenting out the sys.audit lines.

https://docs.python.org/3/library/pty.html presents us with an example usage of 
pty.spawn. This example mimics script(1). However, the script(1) from 
util-linux has fantastic signal handing that pty.spawn does not directly 
provide. In fact, Lib/pty.py says "Bugs: No signal handling. Doesn't set slave 
termios and window size."

xterm(1) on Debian 10 GNU/Linux was used to test the pty.spawn example 
mentioned above; upon resizing the xterm(1) window, the output of programs such 
as ls(1) became scattered and hard to visually parse.

This patch does not modify any of the functions that are already present in 
Lib/pty. Instead, it exposes a new function called "wspawn" [ pty.wspawn ]. 
This is like pty.spawn + the following differences.

1. Window size is set at the beginning.
2. A SIGWINCH handler is registered. The old handler is saved and restored 
later.
3. If the above two steps fail, then cleanup is done, and an exception is 
raised, so that the programmer can catch the exception and use pty.spawn 
instead.
4. Unlike pty.spawn, this does not depend on OSError to break out of the parent 
mainloop. Instead, the main loop calls select with an adjustable  timeout, so 
that waitpid with WNOHANG can be called periodically to check if the spawned 
child process has undergone an alteration of state.
5. While the return value is same as that of pty.spawn, this accepts an extra 
optional "timeout" argument for the select call.

The aforementioned pty.spawn example now works well with window resizing if 
pty.wspawn is used in place of pty.spawn.

Signed-off-by: Soumendra Ganguly 

--
components: Library (Lib)
files: pty.diff
keywords: patch
messages: 374926
nosy: soumendra
priority: normal
severity: normal
status: open
title: Add window resizing support [ SIGWINCH ] to Lib/pty
type: enhancement
versions: Python 3.10, Python 3.7, Python 3.8, Python 3.9
Added file: https://bugs.python.org/file49372/pty.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com