aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-07-27 00:55:07 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-07-27 00:55:07 +0200
commit3ec5f22f6808ada0356ab544f58d9d06816288fd (patch)
treecb2b1969df8162430907544b9eeb6eadcb7c29cf
parent7211fe0f3a1d5724bef5e1462995fae6f2a3a343 (diff)
downloadxutil-3ec5f22f6808ada0356ab544f58d9d06816288fd.tar.gz
Add 'waitstdin' utilityHEADmaster
-rw-r--r--etc/waitstdin.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/etc/waitstdin.c b/etc/waitstdin.c
new file mode 100644
index 0000000..cf05cfb
--- /dev/null
+++ b/etc/waitstdin.c
@@ -0,0 +1,20 @@
+/*
+ * waitstdin -- wait for text on stdin
+ * $ cc -O2 -o waitstdin waitstdin.c
+ */
+
+#include <sys/select.h>
+#include <sys/wait.h>
+
+int
+main()
+{
+ fd_set readfds;
+
+ FD_ZERO(&readfds);
+ FD_SET(0, &readfds);
+ if(select(1, &readfds, NULL, NULL, NULL) == -1)
+ return 1;
+
+ return 0;
+}