Merge "add SIGTERM handler for exit gracefully" into devel
authorpark <sk7.park@samsung.com>
Thu, 1 Jun 2017 09:39:18 +0000 (09:39 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Thu, 1 Jun 2017 09:39:18 +0000 (09:39 +0000)
1  2 
tools/mic

diff --combined tools/mic
+++ b/tools/mic
@@@ -27,6 -27,7 +27,7 @@@
   'create, chroot, convert' and also some parameters for command 'mic'.
  """
  import os
+ import signal
  import sys
  import errno
  
@@@ -198,6 -199,12 +199,12 @@@ def main(argv)
                          return True
                      return False
  
+     def sigterm_handler(signal, frame):
+         raise errors.Abort('\nSIGTERM catched, program aborted.')
+     # Add SIGTERM handler for exit gracefully
+     signal.signal(signal.SIGTERM, sigterm_handler)
      # Create top level parser
      epilog = "Try 'mic SUBCOMMAND --help' for help on a specific subcommand."
      description = "mic - the Image Creation tool"
      if args.debug:
          try:
              import rpm
 -            rpm.setVerbosity(rpm.RPMLOG_NOTICE)
 +            rpm.setVerbosity(rpm.RPMLOG_DEBUG)
          except ImportError:
              pass