一个OSX用户submitted a bug,CTRL+Y通过dsusp导致在python程序尝试读取stdin时发送sigtsp。下面的代码可以解决这个问题:(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)
os.uname()
或类似的方法?在termios.VDSUSP
不存在,即使在有它的系统上也是如此。它失踪有什么原因吗?在stty dsusp undef
,所以没有注意到。在要查看此挂起行为,请运行cat
并在OSX或其他具有此功能的程序上输入CTRL+YReturn。在
{1}我不需要检查计算机的实际行为。 然而,在调查这个问题时,我遇到了issue 7695 in Python bug tracker。似乎只有从3.4以后,
VDSUSP
才在termios
中可用。在Glibc documentation,意思是
因此,我建议您检查
VDSUSP
在termios
中的存在性,它将从3.4开始一直存在;否则将返回到它应该与BSD和您的OS X相匹配;Hurd是一个很大的问号,因为我无法确定您的修复是否完全正确(我想它在所有BSD版本上都会起类似的作用)。在
更简单的方法是:
^{pr2}$至少这不会破坏我的Linux,
stty
命令本身和-g
等都是POSIX标准。在相关问题 更多 >
编程相关推荐