| Index: base/files/file_util_posix.cc
|
| diff --git a/base/files/file_util_posix.cc b/base/files/file_util_posix.cc
|
| index 42de9316f1c9b02aa803feb8113c6a03d958e5c7..a8db2599c642ff920e87533f0bcb6566a7253168 100644
|
| --- a/base/files/file_util_posix.cc
|
| +++ b/base/files/file_util_posix.cc
|
| @@ -351,6 +351,29 @@ bool CopyDirectory(const FilePath& from_path,
|
| }
|
| #endif // !defined(OS_NACL_NONSFI)
|
|
|
| +bool CreateLocalNonBlockingPipe(int fds[2]) {
|
| +#if defined(OS_LINUX)
|
| + return pipe2(fds, O_CLOEXEC | O_NONBLOCK) == 0;
|
| +#else
|
| + int raw_fds[2];
|
| + if (pipe(raw_fds) != 0)
|
| + return false;
|
| + ScopedFD fd_out(raw_fds[0]);
|
| + ScopedFD fd_in(raw_fds[1]);
|
| + if (!SetCloseOnExec(fd_out.get()))
|
| + return false;
|
| + if (!SetCloseOnExec(fd_in.get()))
|
| + return false;
|
| + if (!SetNonBlocking(fd_out.get()))
|
| + return false;
|
| + if (!SetNonBlocking(fd_in.get()))
|
| + return false;
|
| + fds[0] = fd_out.release();
|
| + fds[1] = fd_in.release();
|
| + return true;
|
| +#endif
|
| +}
|
| +
|
| bool SetNonBlocking(int fd) {
|
| const int flags = fcntl(fd, F_GETFL);
|
| if (flags == -1)
|
| @@ -362,6 +385,21 @@ bool SetNonBlocking(int fd) {
|
| return true;
|
| }
|
|
|
| +bool SetCloseOnExec(int fd) {
|
| +#if defined(OS_NACL_NONSFI)
|
| + const int flags = 0;
|
| +#else
|
| + const int flags = fcntl(fd, F_GETFD);
|
| + if (flags == -1)
|
| + return false;
|
| + if (flags & FD_CLOEXEC)
|
| + return true;
|
| +#endif // defined(OS_NACL_NONSFI)
|
| + if (HANDLE_EINTR(fcntl(fd, F_SETFD, flags | FD_CLOEXEC)) == -1)
|
| + return false;
|
| + return true;
|
| +}
|
| +
|
| bool PathExists(const FilePath& path) {
|
| ThreadRestrictions::AssertIOAllowed();
|
| #if defined(OS_ANDROID)
|
|
|