diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/stpd/ChangeLog | 9 | ||||
-rw-r--r-- | runtime/stpd/librelay.c | 23 | ||||
-rw-r--r-- | runtime/stpd/stpd.c | 7 |
3 files changed, 38 insertions, 1 deletions
diff --git a/runtime/stpd/ChangeLog b/runtime/stpd/ChangeLog index 2fd03259..e72ec4d0 100644 --- a/runtime/stpd/ChangeLog +++ b/runtime/stpd/ChangeLog @@ -1,3 +1,12 @@ +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. + 2005-10-19 Tom Zanussi <zanussi@us.ibm.com> * librelay.c: Move output_file var to stpd.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 */ diff --git a/runtime/stpd/stpd.c b/runtime/stpd/stpd.c index 9587d29f..c12ca096 100644 --- a/runtime/stpd/stpd.c +++ b/runtime/stpd/stpd.c @@ -37,6 +37,7 @@ int merge = 1; int verbose = 0; int enable_relayfs = 1; int target_pid = 0; +int driver_pid = 0; unsigned int buffer_size = 0; char *modname = NULL; char *modpath = NULL; @@ -66,6 +67,7 @@ static void usage(char *prog) fprintf(stderr, "-c cmd. Command \'cmd\' will be run and stpd will exit when it does.\n"); fprintf(stderr, " _stp_target will contain the pid for the command.\n"); fprintf(stderr, "-t pid. Sets _stp_target to pid.\n"); + fprintf(stderr, "-d pid. Pass the systemtap driver's pid.\n"); fprintf(stderr, "-b buffer size. The systemtap module will specify a buffer size.\n"); fprintf(stderr, "-o FILE. Send output to FILE.\n"); fprintf(stderr, " Setting one here will override that value. The value should be\n"); @@ -79,7 +81,7 @@ int main(int argc, char **argv) int c, status; pid_t pid; - while ((c = getopt(argc, argv, "mpqrb:n:t:c:vo:")) != EOF) + while ((c = getopt(argc, argv, "mpqrb:n:t:d:c:vo:")) != EOF) { switch (c) { case 'm': @@ -112,6 +114,9 @@ int main(int argc, char **argv) case 't': target_pid = atoi(optarg); break; + case 'd': + driver_pid = atoi(optarg); + break; case 'c': target_cmd = optarg; break; |