blob: e39834ff4708f7ccb74bb4d85c4f9ec6db0f6675 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include <fcntl.h>
#include <unistd.h>
int pipe2(int pipefd[2], int flags)
{
int r;
if ((r = pipe(pipefd)) < 0)
return r;
if (flags & O_CLOEXEC) {
(void) fcntl(pipefd[0], F_SETFD, FD_CLOEXEC);
(void) fcntl(pipefd[1], F_SETFD, FD_CLOEXEC);
}
if (flags & O_NONBLOCK) {
(void) fcntl(pipefd[0], F_SETFL, O_NONBLOCK);
(void) fcntl(pipefd[1], F_SETFL, O_NONBLOCK);
}
return 0;
}
|