You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
'import readline' hangs when launching with '&' on BSD and OS X #59097
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/ronaldoussoren'closed_at=<Date2012-11-30.14:24:18.742>created_at=<Date2012-05-23.18:55:18.815>labels= ['type-bug', 'invalid']
title="'import readline' hangs when launching with '&' on BSD and OS X"updated_at=<Date2012-11-30.14:24:18.741>user='https://bugs.python.org/olivier-mattelaer'
I have found a strange behavior of the import command for the routine readline:
The commands (put in the file test.py) is simply:
import readline
print readline.__doc__
If I run this programs "normally" (i.e. python2.x test.py) everything runs normally:
[tmp]$ python2.7 tmp.py
Importing this module enables command line editing using GNU readline.
But if I launched it in the following way:
python2.X test.py &
It's stops before finishing the import command (so no output even if I print the output into a file).
This doesn't raise any error just stop the program.
I tried to add a try...except...finally... but even the finally statement is not executed.
Of course, I realize that readline is not that interesting to load with that options. So I would be more than happy if you could indicate me a way to either detect that the user launch the program with '&' or a way to avoid readline to stop the program in this situations.
But, on Debian and Ubuntu, neither case hangs. Also, on OS X, the same hang behavior is observed when linked with either GNU readline or BSD libedit. I'm not sure what the significant difference here is: possibly a BSDism vs Linuxism?
changed the title [-]'import readline' fails when launching with '&'[/-][+]'import readline' hangs when launching with '&' on BSD and OS X[/+]on May 23, 2012
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).
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:
Activity
olivier-mattelaer commentedon May 23, 2012
Hi Everyone,
I have found a strange behavior of the import command for the routine readline:
The commands (put in the file test.py) is simply:
import readline
print readline.__doc__
If I run this programs "normally" (i.e. python2.x test.py) everything runs normally:
[tmp]$ python2.7 tmp.py
Importing this module enables command line editing using GNU readline.
But if I launched it in the following way:
python2.X test.py &
It's stops before finishing the import command (so no output even if I print the output into a file).
This doesn't raise any error just stop the program.
I tried to add a try...except...finally... but even the finally statement is not executed.
Of course, I realize that readline is not that interesting to load with that options. So I would be more than happy if you could indicate me a way to either detect that the user launch the program with '&' or a way to avoid readline to stop the program in this situations.
Thanks a lot,
Olivier
ned-deily commentedon May 23, 2012
I took a quick look at this. It's not just OS X, the following also fails on FreeBSD 8.2:
It seems to be hanging on a read from stdin, as adding a redirect of stdin to /dev/null prevents the hang:
But, on Debian and Ubuntu, neither case hangs. Also, on OS X, the same hang behavior is observed when linked with either GNU readline or BSD libedit. I'm not sure what the significant difference here is: possibly a BSDism vs Linuxism?
[-]'import readline' fails when launching with '&'[/-][+]'import readline' hangs when launching with '&' on BSD and OS X[/+]ronaldoussoren commentedon Oct 22, 2012
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:
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:
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.
olivier-mattelaer commentedon Oct 22, 2012
Thanks a lot Ronald.
Cheers,
Olivier