From 6d5746d617385978fb316ac90cc05eaa0f39b8b9 Mon Sep 17 00:00:00 2001 From: Adrian Likins Date: Tue, 25 Sep 2007 14:20:17 -0400 Subject: catch some potentially bad args to the process.kill method We don't want empty args to end up killing the calling process, aka, funcd, so we filter those out. --- modules/process.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/modules/process.py b/modules/process.py index 2c40f9b..78e5aea 100755 --- a/modules/process.py +++ b/modules/process.py @@ -16,6 +16,7 @@ # other modules import sub_process +import codes # our modules from modules import func_module @@ -54,8 +55,16 @@ class ProcessModule(func_module.FuncModule): return results - def kill(self,pid,level=""): - rc = sub_process.call(["/bin/kill", pid, level], executable="/bin/kill", shell=False) + def kill(self,pid,signal="TERM"): + if pid == "0": + raise codes.FuncException("Killing pid group 0 not permitted") + if signal == "": + # this is default /bin/kill behaviour, it claims, but enfore it anyway + signal = "-TERM" + if signal[0] != "-": + signal = "-%s" % signal + rc = sub_process.call(["/bin/kill",signal, pid], executable="/bin/kill", shell=False) + print rc return rc def pkill(self,name,level=""): -- cgit