diff options
Diffstat (limited to 'nacl/curvecp/open_write.c')
-rw-r--r-- | nacl/curvecp/open_write.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/nacl/curvecp/open_write.c b/nacl/curvecp/open_write.c new file mode 100644 index 00000000..e23752d1 --- /dev/null +++ b/nacl/curvecp/open_write.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 | |||
7 | int open_write(const char *fn) | ||
8 | { | ||
9 | #ifdef O_CLOEXEC | ||
10 | return open(fn,O_CREAT | O_WRONLY | O_NONBLOCK | O_CLOEXEC,0644); | ||
11 | #else | ||
12 | int fd = open(fn,O_CREAT | O_WRONLY | O_NONBLOCK,0644); | ||
13 | if (fd == -1) return -1; | ||
14 | fcntl(fd,F_SETFD,1); | ||
15 | return fd; | ||
16 | #endif | ||
17 | } | ||