summaryrefslogtreecommitdiff
path: root/nacl/curvecp/open_read.c
diff options
context:
space:
mode:
Diffstat (limited to 'nacl/curvecp/open_read.c')
-rw-r--r--nacl/curvecp/open_read.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/nacl/curvecp/open_read.c b/nacl/curvecp/open_read.c
new file mode 100644
index 00000000..cea667b5
--- /dev/null
+++ b/nacl/curvecp/open_read.c
@@ -0,0 +1,17 @@
1#include <sys/types.h>
2#include <sys/stat.h>
3#include <unistd.h>
4#include <fcntl.h>
5#include "open.h"
6
7int open_read(const char *fn)
8{
9#ifdef O_CLOEXEC
10 return open(fn,O_RDONLY | O_NONBLOCK | O_CLOEXEC);
11#else
12 int fd = open(fn,O_RDONLY | O_NONBLOCK);
13 if (fd == -1) return -1;
14 fcntl(fd,F_SETFD,1);
15 return fd;
16#endif
17}