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/03/11 18:05:20 UTC
[6/8] mesos git commit: Windows: [1/3] Add platform-dependent
`os::execlp`.
Windows: [1/3] Add platform-dependent `os::execlp`.
Review: https://reviews.apache.org/r/44075/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e48794b8
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e48794b8
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e48794b8
Branch: refs/heads/master
Commit: e48794b8b0c8a97682825793e416242d1e79ec38
Parents: ae873f2
Author: Alex Clemmer <cl...@gmail.com>
Authored: Fri Mar 11 11:29:20 2016 -0500
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Fri Mar 11 12:04:13 2016 -0500
----------------------------------------------------------------------
.../stout/include/stout/os/posix/shell.hpp | 30 +++++++++++---------
.../stout/include/stout/os/windows/shell.hpp | 30 ++++++++++++--------
2 files changed, 35 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/e48794b8/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/shell.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/shell.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/shell.hpp
index e0039fd..76af655 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/shell.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/shell.hpp
@@ -30,6 +30,17 @@
namespace os {
+namespace Shell {
+// Canonical constants used as platform-dependent args to `exec` calls.
+// name() is the command name, arg0() is the first argument received
+// by the callee, usualy the command name and arg1() is the second
+// command argument received by the callee.
+
+ constexpr const char* name = "sh";
+ constexpr const char* arg0 = "sh";
+ constexpr const char* arg1 = "-c";
+} // namespace Shell {
+
/**
* Runs a shell command with optional arguments.
*
@@ -101,19 +112,6 @@ Try<std::string> shell(const std::string& fmt, const T&... t)
return stdout.str();
}
-
-// Canonical constants used as platform-dependent args to `exec` calls.
-// name() is the command name, arg0() is the first argument received
-// by the callee, usualy the command name and arg1() is the second
-// command argument received by the callee.
-struct Shell
-{
- static constexpr const char* name = "sh";
- static constexpr const char* arg0 = "sh";
- static constexpr const char* arg1 = "-c";
-};
-
-
// Executes a command by calling "/bin/sh -c <command>", and returns
// after the command has been completed. Returns 0 if succeeds, and
// return -1 on error (e.g., fork/exec/waitpid failed). This function
@@ -143,6 +141,12 @@ inline int system(const std::string& command)
}
}
+template<typename... T>
+inline int execlp(const char* file, T... t)
+{
+ return ::execlp(file, t...);
+}
+
} // namespace os {
#endif // __STOUT_OS_POSIX_SHELL_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/e48794b8/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp
index 42e2ee1..3dbe624 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/shell.hpp
@@ -23,26 +23,26 @@
namespace os {
+namespace Shell {
+// Canonical constants used as platform-dependent args to `exec` calls.
+// name() is the command name, arg0() is the first argument received
+// by the callee, usualy the command name and arg1() is the second
+// command argument received by the callee.
+
+ constexpr const char* name = "sh";
+ constexpr const char* arg0 = "sh";
+ constexpr const char* arg1 = "-c";
+} // namespace Shell {
+
// Runs a shell command formatted with varargs and return the return value
// of the command. Optionally, the output is returned via an argument.
// TODO(vinod): Pass an istream object that can provide input to the command.
template <typename... T>
-Try<std::string> shell(const std::string& fmt, const T&... t)
+Try<std::string> shell(const std::string& fmt, const T... t)
{
UNIMPLEMENTED;
}
-// Canonical constants used as platform-dependent args to `exec` calls.
-// name() is the command name, arg0() is the first argument received
-// by the callee, usualy the command name and arg1() is the second
-// command argument received by the callee.
-struct Shell
-{
- static constexpr const char* name = "cmd.exe";
- static constexpr const char* arg0 = "cmd.exe";
- static constexpr const char* arg1 = "/c";
-};
-
// Executes a command by calling "cmd /c <command>", and returns
// after the command has been completed. Returns 0 if succeeds, and
// return -1 on error
@@ -52,6 +52,12 @@ inline int system(const std::string& command)
_P_WAIT, Shell::name, Shell::arg0, Shell::arg1, command.c_str());
}
+template<typename... T>
+inline int execlp(const char* file, T... t)
+{
+ exit(::_spawnlp(_P_WAIT, file, t...));
+}
+
} // namespace os {
#endif // __STOUT_OS_WINDOWS_SHELL_HPP__