Ctrl-C handler, how to override?
Aldo Cortesi
aldo at nullcube.com
Wed Oct 2 20:02:52 EDT 2002
Thus spake Bruce Edge (edgebruce at yahoo.com):
> How the @#$!$ do override the SIGINT handler?
>
> I can create handlers for other signals, but not for SIGINT:
>
> >>> getsignal(SIGINT)
> <built-in function default_int_handler>
> >>> def handler(signum, frame):
> ... print "got signal", signum
> >>> signal(SIGINT, handler)
> 1
> >>> getsignal(SIGINT)
> <function handler at 0x81466f4>
>
> ...Looks OK so far, but Ctrl-C's still call the default handler:
>
> >>>
> KeyboardInterrupt
> >>>
> KeyboardInterrupt
> http://mail.python.org/mailman/listinfo/python-list
Bruce,
What you're seeing is a side-effect of running your code in
the interactive interpreter. Your code works fine when
run from a file.
Cheers,
Aldo
--
Aldo Cortesi
aldo at nullcube.com
http://www.nullcube.com
More information about the Python-list
mailing list