classification
Title: curses' sigwinch handler isn't visible from python
Type: behavior Stage: needs patch
Components: Extension Modules Versions: Python 3.7, Python 3.6, Python 2.7
process
Status: open Resolution:
Dependencies: 3948 Superseder:
Assigned To: Nosy List: ajaksu2, serhiy.storchaka, shish, vstinner
Priority: normal Keywords:

Created on 2008-09-23 21:18 by shish, last changed 2017-11-02 11:42 by vstinner.

Messages (4)
msg73668 - (view) Author: Shish (shish) Date: 2008-09-23 21:18
after the first initscr() sigwinch is handled as expected, but then my 
app needs to ignore sigwinch, leave curses to view the output from 
something, come back into curses, and start listening for sigwinch 
again. The signal(SIGWINCH, SIG_IGN) call doesn't return the old, 
working signal handler; it returns 0 -- thus trying to re-set the 
signal handler doesn't work.

(The reason for ignoring the signal is that if the window is resized 
while the external app is running, python's wait() is interrupted)

Having the handler visible from python would also make curses play 
nicer with readline, as the app could mediate signal handling (see 
issue #3948)
msg87950 - (view) Author: Daniel Diniz (ajaksu2) (Python triager) Date: 2009-05-17 02:42
Shish,
Can you provide a short test script? I think this might also be related
to issue 1687125.
msg88023 - (view) Author: Shish (shish) Date: 2009-05-18 09:41
in its simplest form, this shows the bug -- signal.getsignal does not 
return the original signal handler (the "tell the app to resize itself" 
one that curses installs), and so, the original signal handler cannot 
be re-activated after being temporarily disabled

~~~~~~~~~~~~~~

import curses
import signal

curses.initscr()
old_winch = signal.getsignal(signal.SIGWINCH)
curses.endwin()
print old_winch
msg305419 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-11-02 11:42
> The signal(SIGWINCH, SIG_IGN) call doesn't return the old, working signal handler; it returns 0

See bpo-13285: "signal module ignores external signal changes".

By the way, I recently modified test_curses to save/restore signal handlers: see bpo-31629.
History
Date User Action Args
2017-11-02 11:42:38vstinnersetmessages: + msg305419
2017-11-01 18:17:57serhiy.storchakasetnosy: + vstinner, serhiy.storchaka

versions: + Python 3.6, Python 3.7, - Python 3.3, Python 3.4
2013-04-16 14:55:35r.david.murraysetstage: test needed -> needs patch
versions: + Python 2.7, Python 3.3, Python 3.4, - Python 2.6
2009-05-18 09:41:24shishsetmessages: + msg88023
2009-05-17 02:42:48ajaksu2setpriority: normal

dependencies: + readline steals sigwinch
type: behavior
versions: + Python 2.6, - Python 2.4
nosy: + ajaksu2

messages: + msg87950
stage: test needed
2008-09-23 21:18:28shishcreate