#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>
("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());
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;
}