Bug 9068 - Importing samba disables KeyboardInterrupt
Summary: Importing samba disables KeyboardInterrupt
Alias: None
Product: Samba 4.0
Classification: Unclassified
Component: Python (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Jelmer Vernooij
QA Contact: samba4-qa@samba.org
Depends on:
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.