* Refactoring.
This commit is contained in:
@@ -491,3 +491,16 @@ Strings unpackStrings(const string & s)
|
||||
|
||||
return strings;
|
||||
}
|
||||
|
||||
|
||||
string statusToString(int status)
|
||||
{
|
||||
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
|
||||
if (WIFEXITED(status))
|
||||
return (format("failed with exit code %2%") % WEXITSTATUS(status)).str();
|
||||
else if (WIFSIGNALED(status))
|
||||
return (format("failed due to signal %2%") % WTERMSIG(status)).str();
|
||||
else
|
||||
return "died abnormally";
|
||||
} else return "succeeded";
|
||||
}
|
||||
|
||||
@@ -221,4 +221,9 @@ string packStrings(const Strings & strings);
|
||||
Strings unpackStrings(const string & s);
|
||||
|
||||
|
||||
/* Convert the exit status of a child as returned by wait() into an
|
||||
error string. */
|
||||
string statusToString(int status);
|
||||
|
||||
|
||||
#endif /* !__UTIL_H */
|
||||
|
||||
Reference in New Issue
Block a user