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/08/27 01:20:02 UTC

[3/6] mesos git commit: Added `os::execvp' in Stout.

Added `os::execvp' in Stout.

On Windows, the semantics of `execvp` are emulated via spawning
and waiting on a child process.

Review: https://reviews.apache.org/r/51217/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8509553d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8509553d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8509553d

Branch: refs/heads/master
Commit: 8509553def821536077a96bdee1ac2a8a5509c7a
Parents: a5f6df6
Author: Daniel Pravat <dp...@outlook.com>
Authored: Fri Aug 26 17:23:20 2016 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Fri Aug 26 18:19:02 2016 -0700

----------------------------------------------------------------------
 3rdparty/stout/include/stout/os/posix/shell.hpp   |  3 +++
 3rdparty/stout/include/stout/os/windows/shell.hpp | 14 ++++++++++++++
 2 files changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/8509553d/3rdparty/stout/include/stout/os/posix/shell.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/posix/shell.hpp b/3rdparty/stout/include/stout/os/posix/shell.hpp
index 1d73ae5..df8fb4c 100644
--- a/3rdparty/stout/include/stout/os/posix/shell.hpp
+++ b/3rdparty/stout/include/stout/os/posix/shell.hpp
@@ -30,6 +30,9 @@
 
 namespace os {
 
+// Import `::execvp` into `os::` namespace.
+using ::execvp;
+
 namespace Shell {
 
 // Canonical constants used as platform-dependent args to `exec`

http://git-wip-us.apache.org/repos/asf/mesos/blob/8509553d/3rdparty/stout/include/stout/os/windows/shell.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/windows/shell.hpp b/3rdparty/stout/include/stout/os/windows/shell.hpp
index c6e141a..8fb48c1 100644
--- a/3rdparty/stout/include/stout/os/windows/shell.hpp
+++ b/3rdparty/stout/include/stout/os/windows/shell.hpp
@@ -104,6 +104,10 @@ inline int system(const std::string& command)
 }
 
 
+// On Windows, the `_spawnlp` call creates a new process.
+// In order to emulate the semantics of `execlp`, we spawn with `_P_WAIT`,
+// which forces the parent process to block on the child. When the child exits,
+// the exit code is propagated back through the parent via `exit()`.
 template<typename... T>
 inline int execlp(const char* file, T... t)
 {
@@ -111,6 +115,16 @@ inline int execlp(const char* file, T... t)
 }
 
 
+// On Windows, the `_spawnvp` call creates a new process.
+// In order to emulate the semantics of `execvp`, we spawn with `_P_WAIT`,
+// which forces the parent process to block on the child. When the child exits,
+// the exit code is propagated back through the parent via `exit()`.
+inline int execvp(const char* file, char* const argv[])
+{
+  exit(::_spawnvp(_P_WAIT, file, argv));
+}
+
+
 // Concatenates multiple command-line arguments and escapes the values.
 // If `arg` is not specified (or takes the value `0`), the function will
 // scan `argv` until a `nullptr` is encountered.