From 0c6296b282d40c4e39f0af6ddde0d6f74e477147 Mon Sep 17 00:00:00 2001 From: fche Date: Thu, 8 Dec 2005 23:49:23 +0000 Subject: 2005-12-08 Frank Ch. Eigler 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 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. --- runtime/stpd/librelay.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'runtime/stpd/librelay.c') 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 */ -- cgit