From fef72506e4a25e754172a885afbc05fc15530523 Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Thu, 18 Feb 2016 23:51:12 +0100 Subject: [PATCH] ctlmgr/gui/master: start subprocesses in new pgroup This only makes a difference on POSIX. It prevents subprocesses from receiving the signals that the parent receives. For ctlmgr and master is cuts down on spam on the console (KeyboardInterrupt tracebacks from all controllers) and enforces that proper termination is followed. This does not help if the parent gets SIGKILL (subprocesses may linger). --- artiq/devices/ctlmgr.py | 2 +- artiq/gui/applets.py | 3 ++- artiq/master/worker.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/artiq/devices/ctlmgr.py b/artiq/devices/ctlmgr.py index 143bcfb38..c9b320602 100644 --- a/artiq/devices/ctlmgr.py +++ b/artiq/devices/ctlmgr.py @@ -86,7 +86,7 @@ class Controller: self.process = await asyncio.create_subprocess_exec( *shlex.split(self.command), stdout=subprocess.PIPE, stderr=subprocess.PIPE, - env=env) + env=env, start_new_session=True) asyncio.ensure_future( LogParser(self._get_log_source).stream_task( self.process.stdout)) diff --git a/artiq/gui/applets.py b/artiq/gui/applets.py index d757c16e1..b25ac1829 100644 --- a/artiq/gui/applets.py +++ b/artiq/gui/applets.py @@ -116,7 +116,8 @@ class AppletDock(QDockWidgetCloseDetect): ) logger.debug("starting command %s for %s", command, self.applet_name) try: - await self.ipc.create_subprocess(*shlex.split(command)) + await self.ipc.create_subprocess(*shlex.split(command), + start_new_session=True) except: logger.warning("Applet %s failed to start", self.applet_name, exc_info=True) diff --git a/artiq/master/worker.py b/artiq/master/worker.py index 0afc11c78..3ac6278ac 100644 --- a/artiq/master/worker.py +++ b/artiq/master/worker.py @@ -87,7 +87,7 @@ class Worker: sys.executable, "-m", "artiq.master.worker_impl", self.ipc.get_address(), str(log_level), stdout=subprocess.PIPE, stderr=subprocess.PIPE, - env=env) + env=env, start_new_session=True) asyncio.ensure_future( LogParser(self._get_log_source).stream_task( self.ipc.process.stdout))