Exceptions: ^z
Donn Cave
donn at u.washington.edu
Wed Nov 10 13:27:14 EST 1999
Quoth Sai Ramanath <sai at sw.ods.com>:
| Is there a way to catch Ctrl-Z which in UNIX lets the user suspend the Python
| shell into background?
|
| I know we can catch Ctrl-C and Ctrl-D using KeyboardInterrupt and EOFError
| respectively.
You'd use signal.signal(signal.SIGTSTP, signal_handler_function)
I wouldn't want to actually do that, myself. Partly because UNIX signal
handling and Python don't get along too well, partly because it doesn't
pay to tinker with the delicate machinery of Berkeley job control.
If all you really want is to turn off this feature, do that with
the terminal driver:
import termios
import TERMIOS
attr = termios.getattr(0)
attr[6][TERMIOS.VSUSP] = '\000' # '\032' sets it back to ^Z
termios.setattr(0, TERMIOS.TCSANOW, attr)
Donn Cave, University Computing Services, University of Washington
donn at u.washington.edu
More information about the Python-list
mailing list