[issue14892] 'import readline' hangs when launching with '&' on BSD and OS X

Ronald Oussoren report at bugs.python.org
Mon Oct 22 12:46:32 CEST 2012


Ronald Oussoren added the comment:

I've just tested this on OSX 10.8.2 and the problem is not present there (that is, 'python -c "import deadline" &' does not hang)

The problem is present on OSX 10.6.8, and when using ksh(1) you can see why the process is stopped:

[1] + Stopped(SIGTTOU)         python -c 'import readline' &

That signal is generated when the program generates output to a tty and the TOSTOP option of stty is active.  Whether or not that option is active is OS configuration (and can be changed using the stty command).

Reading the option:

import termios
lflags = termios.tcgetattr(0)[3]
print (lflags & termios.TOSTOP) != 0

Oddly enough the option off on both OSX 10.6 and 10.8, which point to a bug in OSX 10.6 (or to a misunderstanding of low-level tty programming details on my part which would not be unlikely)

Anyway, there is an easy workaround: before importing readline add:

import signal
signal.signal(signal.SIGTTOU, signal.SIG_IGN)

This ignores the SIGTTOU option and allows me to import readline on the background.

IMHO This issue can be closed because this behavior is not a Python bug but a platform feature.

----------
resolution:  -> invalid
status: open -> pending

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14892>
_______________________________________


More information about the Python-bugs-list mailing list