From bcc2b3536d6efb5857c16704f99b772655981cdd Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mon, 30 Mar 2009 21:18:30 +0200 Subject: PR10016: systemtap kills all processes in process group on signal. * main.cxx (main): Make sure we run in our own process group. --- main.cxx | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'main.cxx') diff --git a/main.cxx b/main.cxx index 055c56b8..23b182eb 100644 --- a/main.cxx +++ b/main.cxx @@ -845,6 +845,16 @@ main (int argc, char * const argv []) // directory. s.translated_source = string(s.tmpdir) + "/" + s.module_name + ".c"; + // We want a new process group so we can use kill (0, sig) to send a + // signal to all children (but not the parent). As done in + // handle_interrupt (). Unless we are already the process group leader. + if (getpgrp() != getpid() && setpgrp() != 0) + { + const char* e = strerror (errno); + if (! s.suppress_warnings) + cerr << "Warning: failed to set new process group: " << e << endl; + } + // Set up our handler to catch routine signals, to allow clean // and reasonably timely exit. setup_signals(&handle_interrupt); -- cgit