summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-10-23 17:12:48 +1100
committerAndrew Tridgell <tridge@samba.org>2009-10-25 13:15:18 +1100
commite7d9f5eea52403f576b636a35fb9889ed82cbf0b (patch)
treef8aae522ec4a3b5cdc42b55b3757d785f2c2af9a /source4/scripting
parenta07eb08870823fa443911d3b857724bde1e3021b (diff)
downloadsamba-e7d9f5eea52403f576b636a35fb9889ed82cbf0b.tar.gz
samba-e7d9f5eea52403f576b636a35fb9889ed82cbf0b.tar.bz2
samba-e7d9f5eea52403f576b636a35fb9889ed82cbf0b.zip
s4-python: fixed annoyance where control-C doesn't kill our python scripts
We want our scripts to die immediately when a user hits control-C. Otherwise we not only annoy the hell out of the user, we also risk db corruption as the control-C could get delivered as an exception which gets mis-interpreted (eg. as a missing db object). We use transactions for all our databases, so the right thing to do in all our command line tools is to die immediately.
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/python/pyglue.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/source4/scripting/python/pyglue.c b/source4/scripting/python/pyglue.c
index 71203d301c..2f7023ea5d 100644
--- a/source4/scripting/python/pyglue.c
+++ b/source4/scripting/python/pyglue.c
@@ -549,5 +549,15 @@ void initglue(void)
PyModule_AddObject(m, "DS_DC_FUNCTION_2003", PyInt_FromLong(DS_DC_FUNCTION_2003));
PyModule_AddObject(m, "DS_DC_FUNCTION_2008", PyInt_FromLong(DS_DC_FUNCTION_2008));
PyModule_AddObject(m, "DS_DC_FUNCTION_2008_R2", PyInt_FromLong(DS_DC_FUNCTION_2008_R2));
+
+ /* 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. In fact, not dying
+ immediately is unsafe as we could end up treating the
+ control-C exception as a different error and try to modify
+ as database incorrectly
+ */
+ signal(SIGINT, SIG_DFL);
}