ustd: fix warning
[ust.git] / ustd / ustd.c
index 7d1eb49cec6de8d51157ca3c377a0d0be8d2318c..adbc3a902ac2bf648a949201bfead9086bb9dc46 100644 (file)
@@ -35,6 +35,7 @@
 #include "ustd.h"
 #include "localerr.h"
 #include "ustcomm.h"
+#include "share.h"
 
 /* return value: 0 = subbuffer is finished, it won't produce data anymore
  *               1 = got subbuffer successfully
@@ -58,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;
@@ -102,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) {
@@ -198,30 +165,6 @@ end:
        return retval;
 }
 
-/* This write is patient because it restarts if it was incomplete.
- */
-
-ssize_t patient_write(int fd, const void *buf, size_t count)
-{
-       const char *bufc = (const char *) buf;
-       int result;
-
-       for(;;) {
-               result = write(fd, bufc, count);
-               if(result <= 0) {
-                       return result;
-               }
-               count -= result;
-               bufc += result;
-
-               if(count == 0) {
-                       break;
-               }
-       }
-
-       return bufc-(const char *)buf;
-}
-
 void decrement_active_buffers(void *arg)
 {
        pthread_mutex_lock(&active_buffers_mutex);
This page took 0.023409 seconds and 4 git commands to generate.