]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/process/test/sparring_partner.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / process / test / sparring_partner.cpp
index 4d672b120c9bd0cdfdb70f8874e1d42350a3c2a8..c628832a15bd4fa87561a9019e06c09ef5e58e1a 100644 (file)
@@ -17,6 +17,7 @@
 #include <boost/range/algorithm_ext/push_back.hpp>
 #include <boost/lambda/lambda.hpp>
 #include <boost/process/environment.hpp>
+#include <boost/process/handles.hpp>
 #include <vector>
 #include <string>
 #include <iterator>
@@ -57,6 +58,7 @@ int main(int argc, char *argv[])
         ("pwd", bool_switch())
         ("query", value<std::string>())
         ("stdin-to-stdout", bool_switch())
+        ("has-handle", value<std::uintptr_t>())
 #if defined(BOOST_POSIX_API)
         ("posix-echo-one", value<std::vector<std::string> >()->multitoken())
         ("posix-echo-two", value<std::vector<std::string> >()->multitoken());
@@ -223,5 +225,15 @@ int main(int argc, char *argv[])
         std::cout << si.dwFlags << std::endl;
     }
 #endif
+    else if (vm.count("has-handle"))
+    {
+#if defined(BOOST_WINDOWS_API)
+        const auto handle = reinterpret_cast<boost::this_process::native_handle_type>(vm["has-handle"].as<std::uintptr_t>());
+#else
+        const auto handle = static_cast<boost::this_process::native_handle_type>(vm["has-handle"].as<std::uintptr_t>());
+#endif
+        auto all_handles = boost::this_process::get_handles();
+        return (std::find(all_handles.begin(), all_handles.end(), handle) != all_handles.end()) ? EXIT_SUCCESS : EXIT_FAILURE;
+    }
     return EXIT_SUCCESS;
 }