Make sure that portageq exits quietly when killed, like emerge does.
authorZac Medico <zmedico@gentoo.org>
Sat, 19 Aug 2006 02:03:02 +0000 (02:03 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 19 Aug 2006 02:03:02 +0000 (02:03 -0000)
svn path=/main/trunk/; revision=4306

bin/portageq

index ef05a28d722f862a199828ecbc6c55532b62421e..f9527a253db7ee0df0aac73f94e4ca7a29b940e8 100755 (executable)
@@ -3,7 +3,23 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-import sys, os
+import sys
+# This block ensures that ^C interrupts are handled quietly.
+try:
+       import signal
+
+       def exithandler(signum, frame):
+               signal.signal(signal.SIGINT, signal.SIG_IGN)
+               signal.signal(signal.SIGTERM, signal.SIG_IGN)
+               sys.exit(1)
+
+       signal.signal(signal.SIGINT, exithandler)
+       signal.signal(signal.SIGTERM, exithandler)
+
+except KeyboardInterrupt:
+       sys.exit(1)
+
+import os
 os.environ["PORTAGE_CALLER"] = "portageq"
 sys.path = ["/usr/lib/portage/pym"]+sys.path