]> git.sur5r.net Git - i3/i3/commitdiff
Remove trailing newline from stdin
authorAxel Wagner <mail@merovius.de>
Wed, 25 Aug 2010 02:58:28 +0000 (04:58 +0200)
committerAxel Wagner <mail@merovius.de>
Wed, 25 Aug 2010 02:58:28 +0000 (04:58 +0200)
i3bar/src/child.c

index 9b4e9aa0db9252dca04f63bbf64bc25d5982d574..054c007f879eaab0f950074e6ddd1767acb75278 100644 (file)
@@ -52,6 +52,8 @@ void stdin_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) {
         n = read(fd, buffer + rec, buffer_len - rec);
         if (n == -1) {
             if (errno == EAGAIN) {
+                /* remove trailing newline and finish up */
+                buffer[rec-1] = '\0';
                 break;
             }
             printf("ERROR: read() failed!");
@@ -66,6 +68,8 @@ void stdin_io_cb(struct ev_loop *loop, ev_io *watcher, int revents) {
                 buffer_len += STDIN_CHUNK_SIZE;
                 FREE(tmp);
             } else {
+                /* remove trailing newline and finish up */
+                buffer[rec-1] = '\0';
                 break;
             }
         }