I am working on an embedded Busybox system running Python 2.7.
Whenever I kill Python using
killall python
while I run an interactive python shell future instances of the interactive python shell break for that session.
So e.g. I have an ssh connection to the device that is currently running the python shell. Now I use "killall python" from another shell. The shell on the first ssh connection closes (as expected) with the message "Terminated". So far this is all expected.
Now I use the "python" command again in the same shell where I had the last python shell. Now I get abnormal behaviour in the sense that none of my input is displayed.
So e.g. if I normally enter "print('test')" I see this:
>>> print('test')
test
>>>
If I do the same after killing python I see this:
>>> test
>>>
So as you see, my input ("print('test')\n") is not displayed as expected. All outputs from the program are visible, though.
To fix this I have to close the connection (e.g. the ssh connection) and start it again. It only affects connections that had the python shell running while I used the killall-command. So if there are multiple ssh connections only the ones are affected that had python running at the time of the killall-command.
It doesn't matter if I use "killall" or just "kill [PID]", the result is the same.
Does anyone know what causes this and how to fix this?
"Local echo" -- printing input you type -- is a toggleable terminal setting. You're getting your terminal into a state where it's turned off. (This can easily happen if a program exits while prompting for password input, which is a particular circumstance where it's common to turn off local echo for security reasons).
To completely reset your terminal to a known-good state, run
stty sane
before restarting Python. To only enable local echo, runstty echo
.