summaryrefslogtreecommitdiff
path: root/portato/helper.py
diff options
context:
space:
mode:
Diffstat (limited to 'portato/helper.py')
-rw-r--r--portato/helper.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/portato/helper.py b/portato/helper.py
index 9328223..cc797b9 100644
--- a/portato/helper.py
+++ b/portato/helper.py
@@ -18,6 +18,7 @@ Some nice functions used in the program.
"""
import traceback, os.path, sys, types
+import os, signal
DEBUG = True
@@ -80,6 +81,21 @@ def debug(*args, **kwargs):
else:
print >> outfile, text
+def send_signal_to_group (sig):
+ """Sends a signal to all processes of our process group (w/o ourselves).
+
+ @param sig: signal number to send
+ @type sig: int"""
+
+ def handler (sig, stack):
+ """Ignores the signal exactly one time and then restores the default."""
+ signal.signal(sig, signal.SIG_DFL)
+
+ signal.signal(sig, handler)
+
+ pgid = os.getpgrp()
+ os.killpg(pgid, sig)
+
def am_i_root ():
"""Returns True if the current user is root, False otherwise.
@rtype: boolean"""