Signed-off-by: Kefu Chai <kchai@redhat.com>
int Accepter::create_selfpipe(int *pipe_rd, int *pipe_wr) {
int selfpipe[2];
+#ifdef HAVE_PIPE2
int ret = ::pipe2(selfpipe, (O_CLOEXEC|O_NONBLOCK));
+#else
+ int ret = ::pipe(selfpipe);
+ if (ret == 0) {
+ for (int i = 0; i < ceph::size(selfpipe); i++) {
+ int f = fcntl(selfpipe[i], F_GETFD);
+ fcntl(selfpipe[i], F_SETFD, f | FD_CLOEXEC | O_NONBLOCK);
+ }
+ }
+#endif
if (ret < 0 ) {
lderr(msgr->cct) << __func__ << " unable to create the selfpipe: "
<< cpp_strerror(errno) << dendl;