mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
eden: no pipe2 on macos, manually CLOEXEC
Summary: as above Reviewed By: simpkins Differential Revision: D13475713 fbshipit-source-id: 94968251516c6b96e5caa9433d5d24a0b40ea025
This commit is contained in:
parent
79b4ba6ac8
commit
9fca886c54
@ -143,11 +143,27 @@ void DaemonStartupLogger::sendResult(ResultType result) {
|
||||
setsid();
|
||||
}
|
||||
|
||||
namespace {
|
||||
void setCloExec(int fd) {
|
||||
#ifndef FOLLY_HAVE_PIPE2
|
||||
fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
|
||||
#else
|
||||
(void)fd;
|
||||
#endif
|
||||
}
|
||||
} // namespace
|
||||
|
||||
File DaemonStartupLogger::createPipe() {
|
||||
// Create the pipe for communication between the processes
|
||||
std::array<int, 2> pipeFDs;
|
||||
#ifdef FOLLY_HAVE_PIPE2
|
||||
auto rc = pipe2(pipeFDs.data(), O_CLOEXEC);
|
||||
#else
|
||||
auto rc = pipe(pipeFDs.data());
|
||||
#endif
|
||||
checkUnixError(rc, "failed to create communication pipes for daemonization");
|
||||
setCloExec(pipeFDs[0]);
|
||||
setCloExec(pipeFDs[1]);
|
||||
pipe_ = folly::File(pipeFDs[1], /*ownsFd=*/true);
|
||||
|
||||
return folly::File(pipeFDs[0], /*ownsFd=*/true);
|
||||
|
Loading…
Reference in New Issue
Block a user