Register emerge exit and signal handlers after parsing options, just before the actio...
authorZac Medico <zmedico@gentoo.org>
Fri, 23 Jun 2006 10:22:59 +0000 (10:22 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 23 Jun 2006 10:22:59 +0000 (10:22 -0000)
svn path=/main/trunk/; revision=3627

bin/emerge

index 3ec1223a34371513ee711e1bfe15d8841b3eed23..70385e5ad66283a114ea3d47cd2cc30a803fa162 100755 (executable)
@@ -245,21 +245,6 @@ def emergelog(mystr,short_msg=None):
                if secpass >= 1:
                        print >> sys.stderr, "emergelog():",e
 
-def emergeexit():
-       """This gets out final log message in before we quit."""
-       if "--pretend" not in myopts:
-               emergelog(" *** terminating.")
-       if "notitles" not in portage.settings.features:
-               xtermTitleReset()
-portage.atexit_register(emergeexit)
-
-def emergeexitsig(signum, frame):
-       signal.signal(signal.SIGINT, signal.SIG_IGN)
-       portage.portageexit()
-       portage_util.writemsg("\n\nExiting on signal %(signal)s\n" % {"signal":signum})
-       sys.exit(100+signum)
-signal.signal(signal.SIGINT, emergeexitsig)
-
 def countdown(secs=5, doing="Starting"):
        if secs:
                print ">>> Waiting",secs,"seconds before starting..."
@@ -3646,6 +3631,22 @@ if __name__ == "__main__":
        if "--debug" in myopts:
                edebug=1
 
+       def emergeexitsig(signum, frame):
+               signal.signal(signal.SIGINT, signal.SIG_IGN)
+               signal.signal(signal.SIGTERM, signal.SIG_IGN)
+               portage_util.writemsg("\n\nExiting on signal %(signal)s\n" % {"signal":signum})
+               sys.exit(100+signum)
+       signal.signal(signal.SIGINT, emergeexitsig)
+       signal.signal(signal.SIGTERM, emergeexitsig)
+
+       def emergeexit():
+               """This gets out final log message in before we quit."""
+               if "--pretend" not in myopts:
+                       emergelog(" *** terminating.")
+               if "notitles" not in portage.settings.features:
+                       xtermTitleReset()
+       portage.atexit_register(emergeexit)
+
        if myaction in ["sync","metadata"] and "--help" not in myopts:
                if "--pretend" in myopts:
                        print "emerge: \"sync\" actions do not support \"--pretend.\""