import subprocess
import time
import os
+import signal
import getopt
def send(target, message):
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]
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."