You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gi...@apache.org on 2018/10/10 23:54:19 UTC
[mesos] 09/19: Updated the ::pipe() system calls to pipe2 in posix
subprocess.
This is an automated email from the ASF dual-hosted git repository.
gilbert pushed a commit to branch 1.4.x
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 1a7b092989c9b7abee957b377e2583a4f74df39f
Author: Gilbert Song <so...@gmail.com>
AuthorDate: Thu Aug 16 11:03:52 2018 -0700
Updated the ::pipe() system calls to pipe2 in posix subprocess.
Review: https://reviews.apache.org/r/68396
(cherry picked from commit 7a7a879310a5c01b69c8a56b3c1d85555888ec3e)
---
3rdparty/libprocess/src/subprocess_posix.cpp | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/3rdparty/libprocess/src/subprocess_posix.cpp b/3rdparty/libprocess/src/subprocess_posix.cpp
index 01e3272..caba704 100644
--- a/3rdparty/libprocess/src/subprocess_posix.cpp
+++ b/3rdparty/libprocess/src/subprocess_posix.cpp
@@ -28,10 +28,12 @@
#include <stout/foreach.hpp>
#include <stout/option.hpp>
#include <stout/os.hpp>
+#include <stout/os/pipe.hpp>
#include <stout/os/strerror.hpp>
#include <stout/strings.hpp>
#include <stout/try.hpp>
+using std::array;
using std::map;
using std::string;
using std::vector;
@@ -46,25 +48,25 @@ Subprocess::IO Subprocess::PIPE()
{
return Subprocess::IO(
[]() -> Try<InputFileDescriptors> {
- int pipefd[2];
- if (::pipe(pipefd) == -1) {
- return ErrnoError("Failed to create pipe");
+ Try<array<int, 2>> pipefd = os::pipe();
+ if (pipefd.isError()) {
+ return Error(pipefd.error());
}
InputFileDescriptors fds;
- fds.read = pipefd[0];
- fds.write = pipefd[1];
+ fds.read = pipefd->at(0);
+ fds.write = pipefd->at(1);
return fds;
},
[]() -> Try<OutputFileDescriptors> {
- int pipefd[2];
- if (::pipe(pipefd) == -1) {
- return ErrnoError("Failed to create pipe");
+ Try<array<int, 2>> pipefd = os::pipe();
+ if (pipefd.isError()) {
+ return Error(pipefd.error());
}
OutputFileDescriptors fds;
- fds.read = pipefd[0];
- fds.write = pipefd[1];
+ fds.read = pipefd->at(0);
+ fds.write = pipefd->at(1);
return fds;
});
}