Bug 9068 - Importing samba disables KeyboardInterrupt
Importing samba disables KeyboardInterrupt
Product: Samba 4.0
Classification: Unclassified
Component: Python
All All
: P5 normal
: ---
Assigned To: Jelmer Vernooij
Depends on:
  Show dependency treegraph
Reported: 2012-07-27 11:09 UTC by Petr Viktorin
Modified: 2012-10-10 07:32 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Petr Viktorin 2012-07-27 11:09:55 UTC
After importing the samba module, SIGINT will no longer raise KeyboardInterrupt, but will rather quit the interpreter uncleanly (exception handlers and finally blocks won't run).

This is due to the following code in source4/scripting/python/pyglue.c:

        /* one of the most annoying things about python scripts is
           that they don't die when you hit control-C. This fixes that
           sillyness. As we do all database operations using
           transactions, this is also safe. 
        signal(SIGINT, SIG_DFL);

The comment obviously doesn't apply to any Python code that might ever use the Python bindings. A library should not make global changes, especially when it's just imported.

Removing the line is easy enough, but it will need to be added individually to all Samba utilities that expect it.

Steps to Reproduce:
run the following program, press Ctrl+C

    import samba
        while True:
        print "Exiting properly"

Actual Results: No message is printed

Expected Results: "Exiting properly" and a traceback is printed
Comment 1 Jelmer Vernooij 2012-09-25 18:53:27 UTC
I've pushed a fix for this to autobuild.
Comment 2 Karolin Seeger 2012-10-10 07:32:34 UTC
Patch has been pushed to autobuild-v4-0-test also.
Will be included in RC3.