summaryrefslogtreecommitdiff
path: root/sal/osl/unx/process.cxx
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2018-10-18 14:30:42 +0300
committerTor Lillqvist <tml@collabora.com>2018-10-19 14:43:05 +0200
commit22a2ed832bae50f85a254f0604d375aeca207c9e (patch)
treed4269487c15685fc1dd8a20319ba89169f79c2e8 /sal/osl/unx/process.cxx
parent9a373521d7a328197a4bf9abeb0a981b7acba896 (diff)
Introduce UnixErrnoString() and use it in sal/osl/unx
The UnixErrnoString() function returns the symbolic name of an errno value, like "ENOENT". For now this is local to sal/osl/unx. If it can't figure out the symbolic name, it returns it as a number followed by the cleartext description (as from strerror()) in parentheses. Rationale why to use this and not strerror(): This is intended to be used in SAL_INFO() and SAL_WARN(). Such messages are intended to be read by developers, not end-users. Developers are (or should be) familiar with symbolic errno names in code anyway. The symbolic names of errno values are (or should be) instantly recognizable as such, they all start with E and are in UPPERCASE. strerror() can be localised although in LibreOffice it apparently isn't as there allegedly aren't setlocale() calls. But, anyway, the error strings might be less familiar to a developer than the symbolc errno names that one uses when coding. When encountering an unfamiliar error string the developer might want to add special handling for that error case in the code. They would need a reverse mapping from error string to errno value, by manually searching <errno.h>, looking at the comments there, hoping the match what strerror() produces, to find the corresponding symbolic errno value. Change-Id: Idc11595d528e8432a32bf474e6791f4ea7262a1e Reviewed-on: https://gerrit.libreoffice.org/61931 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'sal/osl/unx/process.cxx')
-rw-r--r--sal/osl/unx/process.cxx11
1 files changed, 6 insertions, 5 deletions
diff --git a/sal/osl/unx/process.cxx b/sal/osl/unx/process.cxx
index b88e5246d1a7..480bb264a267 100644
--- a/sal/osl/unx/process.cxx
+++ b/sal/osl/unx/process.cxx
@@ -41,6 +41,7 @@
#endif
#include "system.hxx"
+#include "unixerrnostring.hxx"
#if defined(__sun)
# include <sys/procfs.h>
#endif
@@ -174,7 +175,7 @@ static void ChildStatusProc(void *pData)
OSL_ASSERT(geteuid() == 0); /* must be root */
if (! INIT_GROUPS(data.m_name, data.m_gid) || (setuid(data.m_uid) != 0))
- SAL_WARN("sal.osl", "Failed to change uid and guid, errno=" << errno << " (" << strerror(errno) << ")" );
+ SAL_WARN("sal.osl", "Failed to change uid and guid: " << UnixErrnoString(errno));
const rtl::OUString envVar("HOME");
osl_clearEnvironment(envVar.pData);
@@ -234,14 +235,14 @@ static void ChildStatusProc(void *pData)
execv(data.m_pszArgs[0], const_cast<char **>(data.m_pszArgs));
}
- SAL_WARN("sal.osl", "Failed to exec, errno=" << errno << " (" << strerror(errno) << ")");
+ SAL_WARN("sal.osl", "Failed to exec: " << UnixErrnoString(errno));
SAL_WARN("sal.osl", "ChildStatusProc : starting '" << data.m_pszArgs[0] << "' failed");
/* if we reach here, something went wrong */
errno_copy = errno;
if ( !safeWrite(channel[1], &errno_copy, sizeof(errno_copy)) )
- SAL_WARN("sal.osl", "sendFdPipe : sending failed (" << strerror(errno) << ")");
+ SAL_WARN("sal.osl", "sendFdPipe : sending failed: " << UnixErrnoString(errno));
if ( channel[1] != -1 )
close(channel[1]);
@@ -300,7 +301,7 @@ static void ChildStatusProc(void *pData)
if ( child_pid < 0)
{
- SAL_WARN("sal.osl", "Failed to wait for child process, errno=" << errno << " (" << strerror(errno) << ")");
+ SAL_WARN("sal.osl", "Failed to wait for child process: " << UnixErrnoString(errno));
/*
We got another error than EINTR. Anyway we have to wake up the
@@ -341,7 +342,7 @@ static void ChildStatusProc(void *pData)
else
{
SAL_WARN("sal.osl", "ChildStatusProc : starting '" << data.m_pszArgs[0] << "' failed");
- SAL_WARN("sal.osl", "Failed to launch child process, child reports errno=" << status << " (" << strerror(status) << ")");
+ SAL_WARN("sal.osl", "Failed to launch child process, child reports " << UnixErrnoString(status));
/* Close pipe ends */
if ( pdata->m_pInputWrite )