Last active
June 5, 2016 16:10
-
-
Save Lerchensporn/990f83b0ac4277165c64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/bar.c b/bar.c | |
index 68b41ca..b9f2ae5 100644 | |
--- a/bar.c | |
+++ b/bar.c | |
@@ -1,5 +1,6 @@ | |
// vim:sw=4:ts=4:et: | |
#include <stdbool.h> | |
+#include <fcntl.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
@@ -1287,6 +1288,9 @@ main (int argc, char **argv) | |
// Get the fd to Xserver | |
pollin[1].fd = xcb_get_file_descriptor(c); | |
+ // Prevent fgets to block | |
+ fcntl(STDIN_FILENO, F_SETFL, O_NONBLOCK); | |
+ | |
for (;;) { | |
bool redraw = false; | |
@@ -1300,9 +1304,11 @@ main (int argc, char **argv) | |
else break; // ...bail out | |
} | |
if (pollin[0].revents & POLLIN) { // New input, process it | |
- if (fgets(input, sizeof(input), stdin) == NULL) | |
- break; // EOF received | |
- | |
+ *input = 0; | |
+ while (fgets(input, sizeof input, stdin)) { } | |
+ if (!*input) { | |
+ break; | |
+ } | |
parse(input); | |
redraw = true; | |
} |
Same here. ๐
Would like to see this patch upstream...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works for me. ๐