diff options
author | Josh Stone <jistone@redhat.com> | 2009-04-03 13:32:22 -0700 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2009-04-03 13:47:47 -0700 |
commit | 1bcb8a30c3c138373c2b21a5d3820d132dacf162 (patch) | |
tree | a3dcbee586e6effe26228d4f4b2f932661295da4 /runtime/staprun/relay.c | |
parent | a53e0eeb262399f79c0b1b219c7d5f96c2c10fb4 (diff) | |
download | systemtap-steved-1bcb8a30c3c138373c2b21a5d3820d132dacf162.tar.gz systemtap-steved-1bcb8a30c3c138373c2b21a5d3820d132dacf162.tar.xz systemtap-steved-1bcb8a30c3c138373c2b21a5d3820d132dacf162.zip |
PR10032: Trigger cleanup after relay thread errors
When the relay threads encounter an error, they now send SIGTERM to the
rest of the process before the thread exit, so we get a clean shutdown.
For EPIPE in particular, error messages are also suppressed.
Diffstat (limited to 'runtime/staprun/relay.c')
-rw-r--r-- | runtime/staprun/relay.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/runtime/staprun/relay.c b/runtime/staprun/relay.c index 694cb27e..b9796241 100644 --- a/runtime/staprun/relay.c +++ b/runtime/staprun/relay.c @@ -185,7 +185,7 @@ static void *reader_thread(void *data) dbug(3, "cpu=%d poll=%d errno=%d\n", cpu, rc, errno); if (errno != EINTR) { _perr("poll error"); - return(NULL); + goto error_out; } } while ((rc = read(relay_fd[cpu], buf, sizeof(buf))) > 0) { @@ -198,17 +198,24 @@ static void *reader_thread(void *data) remove_file = 1; if (open_outfile(fnum, cpu, remove_file) < 0) { perr("Couldn't open file for cpu %d, exiting.", cpu); - return(NULL); + goto error_out; } wsize = rc; } if (write(out_fd[cpu], buf, rc) != rc) { - perr("Couldn't write to output %d for cpu %d, exiting.", out_fd[cpu], cpu); - return(NULL); + if (errno != EPIPE) + perr("Couldn't write to output %d for cpu %d, exiting.", out_fd[cpu], cpu); + goto error_out; } } } while (!stop_threads); - dbug(3, "exiting thread %d\n", cpu); + dbug(3, "exiting thread for cpu %d\n", cpu); + return(NULL); + +error_out: + /* Signal the main thread that we need to quit */ + kill(getpid(), SIGTERM); + dbug(2, "exiting thread for cpu %d after error\n", cpu); return(NULL); } |