ustd: improve handling of remote app termination
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 29 Sep 2009 00:01:14 +0000 (20:01 -0400)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 29 Sep 2009 00:01:14 +0000 (20:01 -0400)
ustd/ustd.c

index 4a9a14ecdc8d29a9bd9e3b0f56b64d93ae13e5a1..6f4acf8f5e0722b6dd6e9bef8d42a80c49a369b8 100644 (file)
@@ -59,40 +59,6 @@ pthread_mutex_t active_buffers_mutex = PTHREAD_MUTEX_INITIALIZER;
 /* Whether a request to end the program was received. */
 sig_atomic_t terminate_req = 0;
 
-int test_sigpipe(void)
-{
-       sigset_t sigset;
-       int result;
-
-       result = sigemptyset(&sigset);
-       if(result == -1) {
-               PERROR("sigemptyset");
-               return -1;
-       }
-       result = sigaddset(&sigset, SIGPIPE);
-       if(result == -1) {
-               PERROR("sigaddset");
-               return -1;
-       }
-
-       result = sigtimedwait(&sigset, NULL, &(struct timespec){0,0});
-       if(result == -1 && errno == EAGAIN) {
-               /* no signal received */
-               return 0;
-       }
-       else if(result == -1) {
-               PERROR("sigtimedwait");
-               return -1;
-       }
-       else if(result == SIGPIPE) {
-               /* received sigpipe */
-               return 1;
-       }
-       else {
-               assert(0);
-       }
-}
-
 int get_subbuffer(struct buffer_info *buf)
 {
        char *send_msg=NULL;
@@ -103,9 +69,9 @@ int get_subbuffer(struct buffer_info *buf)
 
        asprintf(&send_msg, "get_subbuffer %s", buf->name);
        result = ustcomm_send_request(&buf->conn, send_msg, &received_msg);
-       if(test_sigpipe()) {
-               WARN("process %d destroyed before we could connect to it", buf->pid);
-               retval = GET_SUBBUF_DONE;
+       if(result == -1 && errno == EPIPE || result == 0) {
+               DBG("app died while being traced");
+               retval = GET_SUBBUF_DIED;
                goto end;
        }
        else if(result < 0) {
This page took 0.024423 seconds and 4 git commands to generate.