blob: 0f231834f371287b9b0a52b7a8d0caf2c1620bb8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
/* ISC license. */
#include <skalibs/sysdeps.h>
#include <skalibs/nonposix.h>
#include <sys/stat.h>
#include <errno.h>
#include <skalibs/fcntl.h>
#include <skalibs/djbunix.h>
#ifdef SKALIBS_HASOCLOEXEC
int open2 (char const *s, unsigned int flags)
{
int r ;
do r = open(s, flags) ;
while (r == -1 && errno == EINTR) ;
return r ;
}
#else
int open2 (char const *s, unsigned int flags)
{
int fd ;
do fd = open(s, flags & ~O_CLOEXEC) ;
while (fd == -1 && errno == EINTR) ;
if (fd == -1) return -1 ;
if (flags & O_CLOEXEC && coe(fd) == -1)
{
fd_close(fd) ;
return -1 ;
}
return fd ;
}
#endif
|