[Kimchi-devel] [PATCH 1/2] Make the package update process indendent of Kimchi

Jose Ricardo Ziviani joserz at linux.vnet.ibm.com
Tue Sep 29 12:39:50 UTC 2015


 - This commit forces the package manager to run out of kimchi
   job group, it will also ignore a sigterm signal in order to let
   the package manager running until it finishes by itself.

Signed-off-by: Jose Ricardo Ziviani <joserz at linux.vnet.ibm.com>
---
 plugins/kimchi/swupdate.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/plugins/kimchi/swupdate.py b/plugins/kimchi/swupdate.py
index 84b927f..459b7a2 100644
--- a/plugins/kimchi/swupdate.py
+++ b/plugins/kimchi/swupdate.py
@@ -17,6 +17,8 @@
 # License along with this library; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 
+import signal
+import os
 import subprocess
 import time
 
@@ -110,6 +112,14 @@ class SoftwareUpdate(object):
         self._scanUpdates()
         return self._num2update
 
+    def preUpdate(self):
+        """
+        Make adjustments before executing the command in
+        a child process.
+        """
+        os.setsid()
+        signal.signal(signal.SIGTERM, signal.SIG_IGN)
+
     def doUpdate(self, cb, params):
         """
         Execute the update
@@ -119,7 +129,8 @@ class SoftwareUpdate(object):
 
         cmd = self._pkg_mnger.update_cmd
         proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
-                                stderr=subprocess.PIPE)
+                                stderr=subprocess.PIPE,
+                                preexec_fn=self.preUpdate)
         msgs = []
         while proc.poll() is None:
             msgs.append(proc.stdout.readline())
-- 
1.9.1




More information about the Kimchi-devel mailing list