You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/02/10 18:12:16 UTC
[5/8] mesos git commit: Libprocess: Introduced Hooks for Subprocess.
Libprocess: Introduced Hooks for Subprocess.
Review: https://reviews.apache.org/r/43302
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2ed70dc8
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2ed70dc8
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2ed70dc8
Branch: refs/heads/master
Commit: 2ed70dc84771360329482a3b2087a85e21cdfd4a
Parents: 694723f
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Thu Feb 4 14:54:27 2016 -0500
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Wed Feb 10 18:12:05 2016 +0100
----------------------------------------------------------------------
.../libprocess/include/process/subprocess.hpp | 27 ++++++++++++++++++++
3rdparty/libprocess/src/subprocess.cpp | 5 ++++
2 files changed, 32 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/2ed70dc8/3rdparty/libprocess/include/process/subprocess.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/subprocess.hpp b/3rdparty/libprocess/include/process/subprocess.hpp
index bb50cc3..c12d1c5 100644
--- a/3rdparty/libprocess/include/process/subprocess.hpp
+++ b/3rdparty/libprocess/include/process/subprocess.hpp
@@ -21,6 +21,7 @@
#include <map>
#include <memory>
+#include <mutex>
#include <string>
#include <vector>
@@ -140,6 +141,32 @@ public:
lambda::function<Try<OutputFileDescriptors>()> output;
};
+ /**
+ * A hook can be passed to a `subprocess` call. It provides a way to
+ * inject dynamic implementation behavior between the clone and exec
+ * calls in the implementation of `subprocess`.
+ */
+ struct Hook
+ {
+ /**
+ * Returns an empty list of hooks.
+ */
+ static std::vector<Hook> None() { return std::vector<Hook>(); }
+
+ Hook(const lambda::function<Try<Nothing>(pid_t)>& _parent_callback);
+
+ /**
+ * The callback that must be sepcified for execution after the
+ * child has been cloned, but before it start executing the new
+ * process. This provides access to the child pid after its
+ * initialization to add tracking or modify execution state of
+ * the child before it executes the new process.
+ */
+ const lambda::function<Try<Nothing>(pid_t)> parent_callback;
+
+ friend class Subprocess;
+ };
+
// Some syntactic sugar to create an IO::PIPE redirector.
static IO PIPE();
static IO PATH(const std::string& path);
http://git-wip-us.apache.org/repos/asf/mesos/blob/2ed70dc8/3rdparty/libprocess/src/subprocess.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/subprocess.cpp b/3rdparty/libprocess/src/subprocess.cpp
index ff477e3..581fba6 100644
--- a/3rdparty/libprocess/src/subprocess.cpp
+++ b/3rdparty/libprocess/src/subprocess.cpp
@@ -42,6 +42,11 @@ namespace process {
using InputFileDescriptors = Subprocess::IO::InputFileDescriptors;
using OutputFileDescriptors = Subprocess::IO::OutputFileDescriptors;
+
+Subprocess::Hook::Hook(
+ const lambda::function<Try<Nothing>(pid_t)>& _parent_callback)
+ : parent_callback(_parent_callback) {}
+
namespace internal {
// See the comment below as to why subprocess is passed to cleanup.