Skip to content

Commit 6a42cee

Browse files
committed
Replace use of pipe2 with pipe,fcntl
pipe2 is not supported on macos platform
1 parent c68d370 commit 6a42cee

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

model/setup/async_manager.cc

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
#include <algorithm>
2020
#include <atomic>
2121
#include <condition_variable>
22+
#include <fcntl.h>
2223
#include <mutex>
24+
#include <sys/select.h>
2325
#include <thread>
2426
#include <unistd.h>
2527
#include <vector>
2628

27-
#include "fcntl.h"
2829
#include "log.h"
29-
#include "sys/select.h"
3030

3131
#ifndef TEMP_FAILURE_RETRY
3232
/* Used to retry syscalls that can return EINTR. */
@@ -167,13 +167,23 @@ class AsyncManager::AsyncFdWatcher {
167167
}
168168
// set up the communication channel
169169
int pipe_fds[2];
170-
if (pipe2(pipe_fds, O_NONBLOCK)) {
170+
if (pipe(pipe_fds)) {
171171
ERROR(
172172
"{}: Unable to establish a communication channel to the reading "
173173
"thread",
174174
__func__);
175175
return -1;
176176
}
177+
// configure the fds as non blocking.
178+
if (fcntl(pipe_fds[0], F_SETFL, O_NONBLOCK) ||
179+
fcntl(pipe_fds[1], F_SETFL, O_NONBLOCK)) {
180+
ERROR(
181+
"{}: Unable to configure the communication channel to the reading "
182+
"thread",
183+
__func__);
184+
return -1;
185+
}
186+
177187
notification_listen_fd_ = pipe_fds[0];
178188
notification_write_fd_ = pipe_fds[1];
179189

0 commit comments

Comments
 (0)