123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- #ifndef BOOST_PROCESS_V2_EXIT_CODE_HPP
- #define BOOST_PROCESS_V2_EXIT_CODE_HPP
- #include <boost/process/v2/detail/config.hpp>
- #include <boost/process/v2/error.hpp>
- #if defined(BOOST_PROCESS_V2_STANDALONE)
- #include <asio/associator.hpp>
- #include <asio/async_result.hpp>
- #else
- #include <boost/asio/associator.hpp>
- #include <boost/asio/async_result.hpp>
- #endif
- #if defined(BOOST_PROCESS_V2_POSIX)
- #include <sys/wait.h>
- #endif
- BOOST_PROCESS_V2_BEGIN_NAMESPACE
- #if defined(GENERATING_DOCUMENTATION)
-
- typedef implementation_defined native_exit_code_type;
- bool process_is_running(native_exit_code_type code);
- int evaluate_exit_code(native_exit_code_type code);
- #else
- #if defined(BOOST_PROCESS_V2_WINDOWS)
- typedef unsigned long native_exit_code_type;
- namespace detail
- {
- constexpr native_exit_code_type still_active = 259u;
- }
- inline bool process_is_running(native_exit_code_type code)
- {
- return code == detail::still_active;
- }
- inline int evaluate_exit_code(native_exit_code_type code)
- {
- return static_cast<int>(code);
- }
- #else
- typedef int native_exit_code_type;
- namespace detail
- {
- constexpr native_exit_code_type still_active = 0x17f;
- static_assert(WIFSTOPPED(still_active), "Expected still_active to indicate WIFSTOPPED");
- static_assert(!WIFEXITED(still_active), "Expected still_active to not indicate WIFEXITED");
- static_assert(!WIFSIGNALED(still_active), "Expected still_active to not indicate WIFSIGNALED");
- static_assert(!WIFCONTINUED(still_active), "Expected still_active to not indicate WIFCONTINUED");
- }
- inline bool process_is_running(int code)
- {
- return !WIFEXITED(code) && !WIFSIGNALED(code);
- }
- inline int evaluate_exit_code(int code)
- {
- if (WIFEXITED(code))
- return WEXITSTATUS(code);
- else if (WIFSIGNALED(code))
- return WTERMSIG(code);
- else
- return code;
- }
- #endif
- #endif
- inline error_code check_exit_code(
- error_code &ec, native_exit_code_type native_code,
- const error_category & category = error::get_exit_code_category())
- {
- if (!ec)
- BOOST_PROCESS_V2_ASSIGN_EC(ec, native_code, category);
- return ec;
- }
- BOOST_PROCESS_V2_END_NAMESPACE
- #endif
|