From d24ac86bd4ef4f96c8298499d5b0789731a32a33 Mon Sep 17 00:00:00 2001 From: necoro <> Date: Sun, 12 Aug 2007 07:00:15 +0000 Subject: made emerge pausing work (again?) --- portato.py | 6 ------ portato/gui/gui_helper.py | 15 +++++++++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/portato.py b/portato.py index 7f5308c..646e850 100755 --- a/portato.py +++ b/portato.py @@ -89,12 +89,6 @@ def main (): print _("Validation succeeded.") return elif options.nolistener: - try: - # move this process into a new process group - # this is to be able to kill emerge et al w/o killing ourselves :) - os.setsid() - except OSError: - pass listener.set_send() run() else: # start listener and start us again in root modus diff --git a/portato/gui/gui_helper.py b/portato/gui/gui_helper.py index ebe0bcf..507fa41 100644 --- a/portato/gui/gui_helper.py +++ b/portato/gui/gui_helper.py @@ -476,7 +476,7 @@ class EmergeQueue: self.console.set_pty(master) # start emerge - self.process = Popen(command+options+packages, stdout = slave, stderr = STDOUT, shell = False, env = system.get_environment()) + self.process = Popen(command+options+packages, stdout = slave, stderr = STDOUT, shell = False, env = system.get_environment(), preexec_fn = os.setsid) # remove packages from queue for i in it: @@ -610,8 +610,12 @@ class EmergeQueue: if self.process is not None: self.threadQueue.clear() # remove all pending emerge threads try: - send_signal_to_group(signal.SIGTERM) - debug("Process should be killed") + pgid = os.getpgid(self.process.pid) + os.killpg(pgid, signal.SIGTERM) + debug("Process should be terminated") + if self.process.poll() is None: + os.killpg(pgid, signal.SIGKILL) + debug("Process should be killed") except AttributeError: debug("AttributeError occured ==> process not exisiting - ignore") except OSError: @@ -621,13 +625,12 @@ class EmergeQueue: def stop_emerge (self): if self.process is not None: - # use SIGTSTP in favor of SIGSTOP, as SIGSTOP cannot be blocked and would stop the GUI too - send_signal_to_group(signal.SIGTSTP) + os.killpg(os.getpgid(self.process.pid), signal.SIGSTOP) debug("Process should be stopped") def continue_emerge (self): if self.process is not None: - send_signal_to_group(signal.SIGCONT) + os.killpg(os.getpgid(self.process.pid), signal.SIGCONT) debug("Process should continue") def remove_with_children (self, it, removeNewFlags = True): -- cgit v1.2.3