File indexing completed on 2025-01-18 09:50:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_PROCESS_V2_EXIT_CODE_HPP
0012 #define BOOST_PROCESS_V2_EXIT_CODE_HPP
0013
0014 #include <boost/process/v2/detail/config.hpp>
0015 #include <boost/process/v2/error.hpp>
0016
0017 #if defined(BOOST_PROCESS_V2_STANDALONE)
0018 #include <asio/associator.hpp>
0019 #include <asio/async_result.hpp>
0020 #else
0021 #include <boost/asio/associator.hpp>
0022 #include <boost/asio/async_result.hpp>
0023 #endif
0024
0025 #if defined(BOOST_PROCESS_V2_POSIX)
0026 #include <sys/wait.h>
0027 #endif
0028
0029 BOOST_PROCESS_V2_BEGIN_NAMESPACE
0030
0031 #if defined(GENERATING_DOCUMENTATION)
0032
0033
0034
0035
0036
0037
0038 typedef implementation_defined native_exit_code_type;
0039
0040
0041
0042 bool process_is_running(native_exit_code_type code);
0043
0044
0045 int evaluate_exit_code(native_exit_code_type code);
0046
0047
0048 #else
0049
0050 #if defined(BOOST_PROCESS_V2_WINDOWS)
0051
0052 typedef unsigned long native_exit_code_type;
0053
0054 namespace detail
0055 {
0056 constexpr native_exit_code_type still_active = 259u;
0057 }
0058
0059 inline bool process_is_running(native_exit_code_type code)
0060 {
0061 return code == detail::still_active;
0062 }
0063
0064 inline int evaluate_exit_code(native_exit_code_type code)
0065 {
0066 return static_cast<int>(code);
0067 }
0068
0069 #else
0070
0071 typedef int native_exit_code_type;
0072
0073 namespace detail
0074 {
0075 constexpr native_exit_code_type still_active = 0x7f;
0076 }
0077
0078 inline bool process_is_running(int code)
0079 {
0080 return !WIFEXITED(code) && !WIFSIGNALED(code);
0081 }
0082
0083 inline int evaluate_exit_code(int code)
0084 {
0085 if (WIFEXITED(code))
0086 return WEXITSTATUS(code);
0087 else if (WIFSIGNALED(code))
0088 return WTERMSIG(code);
0089 else
0090 return code;
0091 }
0092
0093 #endif
0094
0095 #endif
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 inline error_code check_exit_code(
0120 error_code &ec, native_exit_code_type native_code,
0121 const error_category & category = error::get_exit_code_category())
0122 {
0123 if (!ec)
0124 BOOST_PROCESS_V2_ASSIGN_EC(ec, native_code, category);
0125 return ec;
0126 }
0127
0128
0129
0130 BOOST_PROCESS_V2_END_NAMESPACE
0131
0132 #endif