You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2018/02/21 22:57:16 UTC

[5/5] mesos git commit: Windows: Added `internal::windows::set_inherit(WindowsFD, bool)`.

Windows: Added `internal::windows::set_inherit(WindowsFD, bool)`.

This function is used on Windows to explicitly enable or disable
inheritance on a handle.

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


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

Branch: refs/heads/master
Commit: c422c97fb6af049bdaa4214c46aac5b4f37bbcac
Parents: faba7df
Author: Akash Gupta <ak...@hotmail.com>
Authored: Thu Feb 1 14:34:05 2018 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Wed Feb 21 14:00:11 2018 -0800

----------------------------------------------------------------------
 .../include/stout/internal/windows/inherit.hpp  | 47 ++++++++++++++++++++
 1 file changed, 47 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c422c97f/3rdparty/stout/include/stout/internal/windows/inherit.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/internal/windows/inherit.hpp b/3rdparty/stout/include/stout/internal/windows/inherit.hpp
new file mode 100644
index 0000000..6da6f8e
--- /dev/null
+++ b/3rdparty/stout/include/stout/internal/windows/inherit.hpp
@@ -0,0 +1,47 @@
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __STOUT_INTERNAL_WINDOWS_INHERIT_HPP__
+#define __STOUT_INTERNAL_WINDOWS_INHERIT_HPP__
+
+#include <stout/error.hpp>
+#include <stout/nothing.hpp>
+#include <stout/try.hpp>
+
+#include <stout/os/windows/fd.hpp>
+#include <stout/windows.hpp>
+
+
+namespace internal {
+namespace windows {
+
+// This function enables or disables inheritance for a Windows file handle.
+//
+// NOTE: By default, handles on Windows are not inheritable, so this is
+// primarily used to enable inheritance when passing handles to child processes,
+// and subsequently disable inheritance.
+inline Try<Nothing> set_inherit(const os::WindowsFD& fd, const bool inherit)
+{
+  const BOOL result = ::SetHandleInformation(
+      fd, HANDLE_FLAG_INHERIT, inherit ? HANDLE_FLAG_INHERIT : 0);
+
+  if (result == FALSE) {
+    return WindowsError();
+  }
+
+  return Nothing();
+}
+
+} // namespace windows {
+} // namespace internal {
+
+#endif // __STOUT_INTERNAL_WINDOWS_INHERIT_HPP__