©2004 by Marc J. Rochkind. All rights reserved. Portions marked "Open Source" may be copied under license.

 

Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ux/uxexitstatus.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2003 by Marc J. Rochkind. All rights reserved.
00003     May be copied only for purposes and under conditions described
00004     on the Web page www.basepath.com/aup/copyright.htm.
00005 
00006     The Example Files are provided "as is," without any warranty;
00007     without even the implied warranty of merchantability or fitness
00008     for a particular purpose. The author and his publisher are not
00009     responsible for any damages, direct or incidental, resulting
00010     from the use or non-use of these Example Files.
00011 
00012     The Example Files may contain defects, and some contain deliberate
00013     coding mistakes that were included for educational reasons.
00014     You are responsible for determining if and how the Example Files
00015     are to be used.
00016 
00017 */
00018 #include "ux.hpp"
00019 
00020 using namespace Ux;
00021 
00022 /**
00023     Stream operator to output status code.
00024 */
00025 std::ostream& Ux::operator<<(std::ostream& s, const ExitStatus& status)
00026 {
00027     int n = (ExitStatus&)status; // use variable in macros because of weird FreeBSD definitions
00028 
00029     if (WIFEXITED(n))
00030         s << "Exit value " << WEXITSTATUS(n);
00031     else {
00032         char *desc;
00033         char *signame = get_macrostr("signal", WTERMSIG(n), &desc);
00034         if (desc[0] == '?')
00035             desc = signame;
00036         if (signame[0] == '?')
00037             s << "Signal #" << WTERMSIG(n);
00038         else
00039             s << desc;
00040         if (WCOREDUMP(n))
00041             s << " - core dumped";
00042         if (WIFSTOPPED(n))
00043             s << " (stopped)";
00044 #if defined(_XOPEN_UNIX) && !defined(LINUX)
00045         else if (WIFCONTINUED(n))
00046             s << " (continued)";
00047 #endif
00048     }
00049     return s;
00050 }

Generated on Fri Apr 23 10:57:05 2004 for AUP2 Example Source by doxygen 1.3.1