You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by vi...@apache.org on 2016/04/25 23:32:25 UTC
[32/50] 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/a450c474
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a450c474
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a450c474
Branch: refs/heads/0.26.x
Commit: a450c474dec7ed23cbf3835f3902d7cda4354ae8
Parents: dac9f4a
Author: Joris Van Remoortere <jo...@gmail.com>
Authored: Thu Feb 4 14:54:27 2016 -0500
Committer: Michael Park <mp...@apache.org>
Committed: Fri Feb 26 20:59:06 2016 -0800
----------------------------------------------------------------------
.../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/a450c474/3rdparty/libprocess/include/process/subprocess.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/subprocess.hpp b/3rdparty/libprocess/include/process/subprocess.hpp
index f17816e..0932def 100644
--- a/3rdparty/libprocess/include/process/subprocess.hpp
+++ b/3rdparty/libprocess/include/process/subprocess.hpp
@@ -23,6 +23,7 @@
#include <map>
#include <memory>
+#include <mutex>
#include <string>
#include <vector>
@@ -124,6 +125,32 @@ public:
}
/**
+ * 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;
+ };
+
+ /**
* @return The operating system PID for this subprocess.
*/
pid_t pid() const { return data->pid; }
http://git-wip-us.apache.org/repos/asf/mesos/blob/a450c474/3rdparty/libprocess/src/subprocess.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/subprocess.cpp b/3rdparty/libprocess/src/subprocess.cpp
index efe0018..3bf3a0b 100644
--- a/3rdparty/libprocess/src/subprocess.cpp
+++ b/3rdparty/libprocess/src/subprocess.cpp
@@ -39,6 +39,11 @@ using std::string;
using std::vector;
namespace process {
+
+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.