From 64dd476d6e921f549db27a22fd92f283313d46b6 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Tue, 26 Nov 2013 19:45:58 -0500 Subject: [PATCH] Required magic to kill the spawned instance. --- irk | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/irk b/irk index 49a083f..6307d65 100755 --- a/irk +++ b/irk @@ -16,6 +16,7 @@ import fileinput import subprocess import time import os +import signal import getopt def send(target, message): @@ -42,7 +43,7 @@ if __name__ == "__main__": except: # If it isn't, spawn an instance print "Spawning an irker instance..." - irkerd = subprocess.Popen("irkerd", shell=True) + irkerd = subprocess.Popen("irkerd", shell=True, preexec_fn=os.setsid) time.sleep(0.5) target = arguments[0] @@ -57,6 +58,7 @@ if __name__ == "__main__": send(target, message) if killafter: if irkerd: - irkerd.terminate() - irkerd.wait() + time.sleep(0.5) + # Magic required because shell=True, terminate() won't work. + os.killpg(irkerd.pid, signal.SIGTERM) print "...terminated." -- 2.26.2