summaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'block.c')
-rw-r--r--block.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/block.c b/block.c
new file mode 100644
index 0000000..40178d8
--- /dev/null
+++ b/block.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/select.h>
+
+// utility to block until stdin has input
+// public domain
+
+int main(int argc, char *argv[]) {
+ fd_set readset;
+ FD_ZERO(&readset);
+ FD_SET(STDIN_FILENO, &readset);
+ if (select(1, &readset, NULL, NULL, NULL) == -1) {
+ perror(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ return 0;
+}