summaryrefslogtreecommitdiffstats
path: root/runtime/stpd/librelay.c
diff options
context:
space:
mode:
authorfche <fche>2005-12-08 23:49:23 +0000
committerfche <fche>2005-12-08 23:49:23 +0000
commit0c6296b282d40c4e39f0af6ddde0d6f74e477147 (patch)
tree2830a3731c452553a7af3d8e0a309f6ac37bdddf /runtime/stpd/librelay.c
parent99675700179e2a22adf8a9492b73864ff8755add (diff)
downloadsystemtap-steved-0c6296b282d40c4e39f0af6ddde0d6f74e477147.tar.gz
systemtap-steved-0c6296b282d40c4e39f0af6ddde0d6f74e477147.tar.xz
systemtap-steved-0c6296b282d40c4e39f0af6ddde0d6f74e477147.zip
2005-12-08 Frank Ch. Eigler <fche@elastic.org>
PR 1937 * buildrun.cxx (run_pass): Pass new "-d PID" option to stpd. Set SIGHUP to SIG_IGN too. 2005-12-08 Frank Ch. Eigler <fche@elastic.org> PR 1937 * stpd.c (main): Support new "-d" option. (usage): Document it. * librelay.c (driver_poll): New function to react to death of driver process. (stp_main_loop): Call it if "-d PID" given. Treat SIGHUP like others.
Diffstat (limited to 'runtime/stpd/librelay.c')
-rw-r--r--runtime/stpd/librelay.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/runtime/stpd/librelay.c b/runtime/stpd/librelay.c
index 9ed408d9..e2beece2 100644
--- a/runtime/stpd/librelay.c
+++ b/runtime/stpd/librelay.c
@@ -84,6 +84,7 @@ extern unsigned int buffer_size;
extern char *modname;
extern char *modpath;
extern int target_pid;
+extern int driver_pid;
extern char *target_cmd;
/* per-cpu buffer info */
@@ -641,6 +642,23 @@ static void sigproc(int signum __attribute__((unused)))
send_request(STP_EXIT, NULL, 0);
}
+static void driver_poll (int signum __attribute__((unused)))
+{
+ /* See if the driver process is still alive. If not, time to exit. */
+ if (kill (driver_pid, 0) < 0)
+ {
+ send_request(STP_EXIT, NULL, 0);
+ return;
+ }
+ else
+ {
+ /* Check again later. */
+ signal (SIGALRM, driver_poll);
+ alarm (10); // any reasonable poll interval
+ }
+}
+
+
/**
* stp_main_loop - loop forever reading data
*/
@@ -659,6 +677,11 @@ int stp_main_loop(void)
signal(SIGINT, sigproc);
signal(SIGTERM, sigproc);
signal(SIGCHLD, sigproc);
+ signal(SIGHUP, sigproc);
+
+ if (driver_pid)
+ driver_poll(0); // And by the way, I'm also the signal handler.
+
dbug("in main loop\n");
while (1) { /* handle messages from control channel */