An OSX user submitted a bug that CTRL+Y causes a python terminal application to be suspended, via dsusp causing SIGTSTP to be sent when the Python program tried to read on stdin. The code below to solves the problem: (context)
import sys
import termios
if sys.platform == 'darwin':
attrs = termios.tcgetattr(0)
VDSUSP = termios.VSUSP + 1
attrs[-1][VDSUSP] = 0
termios.tcsetattr(0, termios.TCSANOW, attrs)
- How can this feature (dsusp) be detected? Is there a heuristic I could use based on
os.uname()
or similar? termios.VDSUSP
doesn't exist, even on systems that have it. Is there a reason it's missing?- How widespread is this behavior of turning it off? Programs that use readline seem to ignore CTRL+Y on OSX, so it's at least reasonably common. I added
stty dsusp undef
to my .bashrc long ago so haven't noticed it.
To see this suspend behavior, run cat
and enter CTRL+Y Return on OSX or something else with this feature.
$ cat
^Y
[1]+ Stopped cat
$ fg
cat
cat: stdin: Resource temporarily unavailable