Skip to content
Snippets Groups Projects
Commit 651a4c6f authored by Adrien Béraud's avatar Adrien Béraud
Browse files

dsh: support macOS for pipe()

Change-Id: If2dbf456f0f2dbc7f04e1dec4db7986ad10f6f54
parent bd09c995
No related branches found
No related tags found
No related merge requests found
...@@ -28,13 +28,25 @@ const int READ_END = 0; ...@@ -28,13 +28,25 @@ const int READ_END = 0;
const int WRITE_END = 1; const int WRITE_END = 1;
void void
create_pipe(int pipe[2]) create_pipe(int apipe[2])
{ {
if (pipe2(pipe, O_CLOEXEC) == -1) { #ifdef __APPLE__
if (pipe(apipe) < 0)
perror("pipe");
if (fcntl(apipe[0], F_SETFD, FD_CLOEXEC) < 0)
perror("unable to set pipe FD_CLOEXEC");
if (fcntl(apipe[1], F_SETFD, FD_CLOEXEC) < 0)
perror("unable to set pipe FD_CLOEXEC");
#else
if (pipe2(apipe, O_CLOEXEC) == -1) {
perror("pipe2"); perror("pipe2");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#endif
} }
void void
child_proc(const int in_pipe[2], child_proc(const int in_pipe[2],
const int out_pipe[2], const int out_pipe[2],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment