Fix: compare write() return value to size
[lttng-tools.git] / src / common / consumer.c
index e0a756a5697c40c7cbbd1ff0887a5c01f61464e3..1e710ab3d9b80fefbbfe2aad58fd050e50d03444 100644 (file)
@@ -1106,7 +1106,7 @@ void lttng_consumer_should_exit(struct lttng_consumer_local_data *ctx)
        do {
                ret = write(ctx->consumer_should_quit[1], "4", 1);
        } while (ret < 0 && errno == EINTR);
-       if (ret < 0) {
+       if (ret < 0 || ret != 1) {
                PERROR("write consumer quit");
        }
 
@@ -1324,7 +1324,7 @@ static int write_relayd_metadata_id(int fd,
        do {
                ret = write(fd, (void *) &hdr, sizeof(hdr));
        } while (ret < 0 && errno == EINTR);
-       if (ret < 0) {
+       if (ret < 0 || ret != sizeof(hdr)) {
                /*
                 * This error means that the fd's end is closed so ignore the perror
                 * not to clubber the error output since this can happen in a normal
This page took 0.023297 seconds and 4 git commands to generate.