From 6034eee6474b3f906e28d16d117a149e42441bd5 Mon Sep 17 00:00:00 2001 From: Axel Wagner Date: Wed, 25 Aug 2010 04:58:28 +0200 Subject: [PATCH] Remove trailing newline from stdin --- i3bar/src/child.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/i3bar/src/child.c b/i3bar/src/child.c index 9b4e9aa0..054c007f 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -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; } } -- 2.39.5