From fa332b71dc71d23f1475ed6c25a6376934ab652a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Sep 2012 20:49:22 +0200 Subject: s4-python: Override SIGINT handler in scripts only. Override the SIGINT handler in a few select cases only, rather than doing so in one of the samba Python modules. I've done this where it matters most; we can add this code to other scripts too if necessary. This means that importing the 'samba' module from a third party application does not have side-effects on the state of the signal handlers. Bug: https://bugzilla.samba.org/show_bug.cgi?id=9068 --- source4/scripting/bin/samba-tool | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/scripting/bin/samba-tool') diff --git a/source4/scripting/bin/samba-tool b/source4/scripting/bin/samba-tool index 8ec6514bbf..bb9662666c 100755 --- a/source4/scripting/bin/samba-tool +++ b/source4/scripting/bin/samba-tool @@ -1,6 +1,7 @@ #!/usr/bin/env python # Unix SMB/CIFS implementation. +# Copyright (C) Jelmer Vernooij 2008-2012 # Copyright (C) Amitay Isaacs 2011 # Copyright (C) Giampaolo Lauria 2011 # @@ -23,6 +24,12 @@ import sys # Find right direction when running from source tree sys.path.insert(0, "bin/python") +# make sure the script dies immediately when hitting control-C, +# rather than raising KeyboardInterrupt. As we do all database +# operations using transactions, this is safe. +import signal +signal.signal(signal.SIGINT, signal.SIG_DFL) + from samba.netcmd.main import cmd_sambatool cmd = cmd_sambatool() subcommand = None -- cgit