blob: dbe31d3a821305697cba5ccf36b5f49efce368a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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;
}
|