Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:10

0001 // Copyright (c) 2021 Klemens D. Morgenstern
0002 //
0003 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0004 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 #ifndef BOOST_PROCESS_V2_IMPL_ERROR_IPP
0006 #define BOOST_PROCESS_V2_IMPL_ERROR_IPP
0007 
0008 #include <boost/process/v2/detail/config.hpp>
0009 #include <boost/process/v2/error.hpp>
0010 #include <boost/process/v2/exit_code.hpp>
0011 
0012 #include <cstdlib>
0013 
0014 #if defined(BOOST_PROCESS_V2_POSIX)
0015 #include <sys/wait.h>
0016 #endif
0017 BOOST_PROCESS_V2_BEGIN_NAMESPACE
0018 
0019 namespace error
0020 {
0021 
0022 namespace detail
0023 {
0024 
0025 struct utf8_category final : public error_category
0026 {
0027     utf8_category() : error_category(0xDAEDu) {}
0028 
0029     const char* name() const noexcept
0030     {
0031         return "process.v2.utf8";
0032     }
0033     std::string message(int value) const
0034     {
0035         switch (static_cast<utf8_conv_error>(value))
0036         {
0037             case utf8_conv_error::insufficient_buffer:
0038                 return "A supplied buffer size was not large enough";
0039             case utf8_conv_error::invalid_character:
0040                 return "Invalid characters were found in a string.";
0041             default:
0042                 return "process.v2.utf8 error";
0043         }
0044     }
0045 };
0046 
0047 
0048 struct exit_code_category final : public error_category
0049 {
0050     exit_code_category() : error_category(0xDAEEu) {}
0051 
0052     const char* name() const noexcept
0053     {
0054         return "process.v2.exit_code";
0055     }
0056     std::string message(int status) const
0057     {
0058         switch (evaluate_exit_code(status))
0059         {
0060             case v2::detail::still_active:
0061                 return "still-active";
0062             case EXIT_SUCCESS:
0063                 return "exit_success";
0064             case EXIT_FAILURE:
0065                 return "exit_failure";
0066             default:
0067 #if defined(BOOST_PROCESS_V2_POSIX)
0068                 if (WIFCONTINUED(status))
0069                     return "continued";
0070                 switch (WTERMSIG(status))
0071                 {
0072 #            if defined(SIGABRT)
0073                     case SIGABRT: return "SIGABRT:   Abort signal from abort(3)";
0074 #            endif
0075 #            if defined(SIGALRM)
0076                     case SIGALRM: return "SIGALRM:   Timer signal from alarm(2)";
0077 #            endif
0078 #            if defined(SIGBUS)
0079                     case SIGBUS: return "SIGBUS:    Bus error (bad memory access)";
0080 #            endif
0081 #            if defined(SIGCHLD)
0082                     case SIGCHLD: return "SIGCHLD:   Child stopped or terminated";
0083 #            endif
0084 #            if defined(SIGCONT)
0085                     case SIGCONT: return "SIGCONT:   Continue if stopped";
0086 #            endif
0087 #            if defined(SIGEMT)
0088                     case SIGEMT: return "SIGEMT:    Emulator trap";
0089 #            endif
0090 #            if defined(SIGFPE)
0091                     case SIGFPE: return "SIGFPE:    Floating-point exception";
0092 #            endif
0093 #            if defined(SIGHUP)
0094                     case SIGHUP: return "SIGHUP:    Hangup detected on controlling terminal";
0095 #            endif
0096 #            if defined(SIGILL)
0097                     case SIGILL: return "SIGILL:    Illegal Instruction";
0098 #            endif
0099 #            if defined(SIGINFO)
0100                     case SIGINFO: return "SIGINFO:   A synonym for SIGPWR";
0101 #            endif
0102 #            if defined(SIGINT)
0103                     case SIGINT: return "SIGINT:    Interrupt from keyboard";
0104 #            endif
0105 #            if defined(SIGIO)
0106                     case SIGIO: return "SIGIO:     I/O now possible (4.2BSD)";
0107 #            endif
0108 #            if defined(SIGKILL)
0109                     case SIGKILL: return "SIGKILL:   Kill signal";
0110 #            endif
0111 #            if defined(SIGLOST)
0112                     case SIGLOST: return "SIGLOST:   File lock lost (unused)";
0113 #            endif
0114 #            if defined(SIGPIPE)
0115                     case SIGPIPE: return "SIGPIPE:   Broken pipe: write to pipe with no";
0116 #            endif
0117 #            if defined(SIGPOLL) && !defined(SIGIO)
0118                     case SIGPOLL: return "SIGPOLL:   Pollable event (Sys V);";
0119 #            endif
0120 #            if defined(SIGPROF)
0121                     case SIGPROF: return "SIGPROF:   Profiling timer expired";
0122 #            endif
0123 #            if defined(SIGPWR)
0124                     case SIGPWR: return "SIGPWR:    Power failure (System V)";
0125 #            endif
0126 #            if defined(SIGQUIT)
0127                     case SIGQUIT: return "SIGQUIT:   Quit from keyboard";
0128 #            endif
0129 #            if defined(SIGSEGV)
0130                     case SIGSEGV: return "SIGSEGV:   Invalid memory reference";
0131 #            endif
0132 #            if defined(SIGSTKFLT)
0133                     case SIGSTKFLT: return "SIGSTKFLT: Stack fault on coprocessor (unused)";
0134 #            endif
0135 #            if defined(SIGSTOP)
0136                     case SIGSTOP: return "SIGSTOP:   Stop process";
0137 #            endif
0138 #            if defined(SIGTSTP)
0139                     case SIGTSTP: return "SIGTSTP:   Stop typed at terminal";
0140 #            endif
0141 #            if defined(SIGSYS)
0142                     case SIGSYS: return "SIGSYS:    Bad system call (SVr4);";
0143 #            endif
0144 #            if defined(SIGTERM)
0145                     case SIGTERM: return "SIGTERM:   Termination signal";
0146 #            endif
0147 #            if defined(SIGTRAP)
0148                     case SIGTRAP: return "SIGTRAP:   Trace/breakpoint trap";
0149 #            endif
0150 #            if defined(SIGTTIN)
0151                     case SIGTTIN: return "SIGTTIN:   Terminal input for background process";
0152 #            endif
0153 #            if defined(SIGTTOU)
0154                     case SIGTTOU: return "SIGTTOU:   Terminal output for background process";
0155 #            endif
0156 #            if defined(SIGURG)
0157                     case SIGURG: return "SIGURG:    Urgent condition on socket (4.2BSD)";
0158 #            endif
0159 #            if defined(SIGUSR1)
0160                     case SIGUSR1: return "SIGUSR1:   User-defined signal 1";
0161 #            endif
0162 #            if defined(SIGUSR2)
0163                     case SIGUSR2: return "SIGUSR2:   User-defined signal 2";
0164 #            endif
0165 #            if defined(SIGVTALRM)
0166                     case SIGVTALRM: return "SIGVTALRM: Virtual alarm clock (4.2BSD)";
0167 #            endif
0168 #            if defined(SIGXCPU)
0169                     case SIGXCPU: return "SIGXCPU:   CPU time limit exceeded (4.2BSD);";
0170 #            endif
0171 #            if defined(SIGXFSZ)
0172                     case SIGXFSZ: return "SIGXFSZ:   File size limit exceeded (4.2BSD);";
0173 #            endif
0174 #            if defined(SIGWINCH)
0175                     case SIGWINCH: return "SIGWINCH:  Window resize signal (4.3BSD, Sun)";
0176 #            endif
0177                     default: return "Unknown signal";
0178                 }
0179 #endif
0180                 return "exited with other error";
0181         }
0182     }
0183 };
0184 
0185 
0186 
0187 
0188 } // namespace detail
0189 
0190 BOOST_PROCESS_V2_DECL const error_category& get_utf8_category()
0191 {
0192     static detail::utf8_category instance;
0193     return instance;
0194 }
0195 
0196 BOOST_PROCESS_V2_DECL const error_category& get_exit_code_category()
0197 {
0198     static detail::exit_code_category instance;
0199     return instance;
0200 }
0201 
0202 }
0203 
0204 BOOST_PROCESS_V2_END_NAMESPACE
0205 
0206 #endif //BOOST_PROCESS_V2_IMPL_ERROR_IPP