summaryrefslogtreecommitdiff
path: root/nonblock.c
diff options
context:
space:
mode:
authorToby Goodwin <toby@paccrat.org>2014-09-02 08:01:39 +0100
committerToby Goodwin <toby@paccrat.org>2015-05-16 21:22:10 +0100
commita8699a58d8632f21e897ea5c4900a15483a9a8ca (patch)
treefd8e7910807eb91bcd79d498582959f1d750f9c6 /nonblock.c
parentd884971193ef4934424b77ae862e8b0ecf70bab3 (diff)
release: rc-1.7.2
Diffstat (limited to 'nonblock.c')
-rw-r--r--nonblock.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/nonblock.c b/nonblock.c
new file mode 100644
index 0000000..dbe31d3
--- /dev/null
+++ b/nonblock.c
@@ -0,0 +1,14 @@
+/* Set stdin to nonblocking. */
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+int main(void) {
+ int flags;
+ flags = fcntl(0, F_GETFL);
+ flags |= O_NONBLOCK;
+ fcntl(0, F_SETFL, (long) flags);
+ flags = read(0, &flags, 1);
+ printf("read returns %d, errno == %d\n", flags, errno);
+ return 0;
+}