From c8a77b86b4f8c91314222a8e12e6e37cf182ee10 Mon Sep 17 00:00:00 2001 From: Toby Goodwin Date: Mon, 1 Oct 2012 20:46:40 +0100 Subject: initial commit --- nonblock.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 nonblock.c (limited to 'nonblock.c') 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 +#include +#include +#include +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; +} -- cgit v1.2.3