summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbhishek Koneru <akoneru@redhat.com>2013-03-20 17:28:10 -0400
committerAbhishek Koneru <akoneru@redhat.com>2013-03-26 15:22:47 -0400
commit3e70f3ea2abd3f6c855ff433b4b1ee5e0312417c (patch)
tree50cb8ecf88bec3443c973cc9ae8fd534e9cf0828
parent64c208345dd15991ba51ed8d976d6504efa94abd (diff)
downloadpki-3e70f3ea2abd3f6c855ff433b4b1ee5e0312417c.tar.gz
pki-3e70f3ea2abd3f6c855ff433b4b1ee5e0312417c.tar.xz
pki-3e70f3ea2abd3f6c855ff433b4b1ee5e0312417c.zip
Handle the Keyboard interrupt gracefully.
Catch the KeyboardInterrupt (Ctrl-C) input during the execution of pkispawn and pkidestroy and display a proper message to user rather than a stacktrace. Ticket #536
-rwxr-xr-xbase/deploy/src/pkidestroy8
-rwxr-xr-xbase/deploy/src/pkispawn8
2 files changed, 16 insertions, 0 deletions
diff --git a/base/deploy/src/pkidestroy b/base/deploy/src/pkidestroy
index 839e1cad5..98ac414ac 100755
--- a/base/deploy/src/pkidestroy
+++ b/base/deploy/src/pkidestroy
@@ -21,6 +21,8 @@
# System Imports
import sys
+import signal
+
if not hasattr(sys, "hexversion") or sys.hexversion < 0x020700f0:
print "Python version %s.%s.%s is too old." % sys.version_info[:3]
print "Please upgrade to at least Python 2.7.0."
@@ -47,6 +49,11 @@ error was:
""" % sys.exc_value
sys.exit(1)
+#Handle the Keyboard Interrupt
+def interrupt_handler(signal, frame):
+ print
+ print '\nUninstallation canceled.'
+ sys.exit(1)
# PKI Deployment Functions
def main(argv):
@@ -251,4 +258,5 @@ def main(argv):
# PKI Deployment Entry Point
if __name__ == "__main__":
+ signal.signal(signal.SIGINT, interrupt_handler)
main(sys.argv)
diff --git a/base/deploy/src/pkispawn b/base/deploy/src/pkispawn
index 65bbaa4a8..447240ecf 100755
--- a/base/deploy/src/pkispawn
+++ b/base/deploy/src/pkispawn
@@ -21,6 +21,8 @@
# System Imports
import sys
+import signal
+
if not hasattr(sys, "hexversion") or sys.hexversion < 0x020700f0:
print "Python version %s.%s.%s is too old." % sys.version_info[:3]
print "Please upgrade to at least Python 2.7.0."
@@ -50,6 +52,11 @@ error was:
""" % sys.exc_value
sys.exit(1)
+#Handle the Keyboard Interrupt
+def interrupt_handler(signal, frame):
+ print
+ print '\nInstallation canceled.'
+ sys.exit(1)
# PKI Deployment Functions
def main(argv):
@@ -402,4 +409,5 @@ def main(argv):
# PKI Deployment Entry Point
if __name__ == "__main__":
+ signal.signal(signal.SIGINT, interrupt_handler)
main(sys.argv)