#endif
int
-evutil_open_closeonexec(const char *pathname, int flags, mode_t mode)
+evutil_open_closeonexec(const char *pathname, int flags, unsigned mode)
{
int fd;
flags |= O_CLOEXEC;
#endif
- fd = open(pathname, flags, mode);
+ if (flags & O_CREAT)
+ fd = open(pathname, flags, (mode_t)mode);
+ else
+ fd = open(pathname, flags);
if (fd < 0)
return -1;
#define EVUTIL_UPCAST(ptr, type, field) \
((type *)(((char*)(ptr)) - evutil_offsetof(type, field)))
-int evutil_open_closeonexec(const char *pathname, int flags, mode_t mode);
+/* As open(pathname, flags, mode), except that the file is always opened with
+ * the close-on-exec flag set. (And the mode argument is mandatory.)
+ */
+int evutil_open_closeonexec(const char *pathname, int flags, unsigned mode);
int evutil_read_file(const char *filename, char **content_out, size_t *len_out,
int is_binary);