execmd statusAsString
This commit is contained in:
parent
03378c55a4
commit
3a9d7f7cb6
@ -10,7 +10,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="docbook-xsl.css">
|
||||
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
|
||||
<meta name="description" content=
|
||||
"Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license can be found at the following location: GNU web site. This document introduces full text search notions and describes the installation and use of the Recoll application. This version describes Recoll 1.31.">
|
||||
"Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license can be found at the following location: GNU web site. This document introduces full text search notions and describes the installation and use of the Recoll application. This version describes Recoll 1.32.">
|
||||
</head>
|
||||
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084"
|
||||
alink="#0000FF">
|
||||
@ -53,7 +53,7 @@ alink="#0000FF">
|
||||
and describes the installation and use of the
|
||||
<span class="application">Recoll</span> application.
|
||||
This version describes <span class=
|
||||
"application">Recoll</span> 1.31.</p>
|
||||
"application">Recoll</span> 1.32.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -443,7 +443,7 @@ alink="#0000FF">
|
||||
<p>This document introduces full text search notions and
|
||||
describes the installation and use of the <span class=
|
||||
"application">Recoll</span> application. It is updated for
|
||||
<span class="application">Recoll</span> 1.31.</p>
|
||||
<span class="application">Recoll</span> 1.32.</p>
|
||||
<p><span class="application">Recoll</span> was for a long
|
||||
time dedicated to Unix-like systems. It was only lately
|
||||
(2015) ported to <span class="application">MS-Windows</span>.
|
||||
|
||||
@ -38,8 +38,8 @@ AM_CPPFLAGS = -Wall -Wno-unused -std=c++11 \
|
||||
-D_GNU_SOURCE \
|
||||
$(DEFS)
|
||||
|
||||
noinst_PROGRAMS = plaintorich textsplit utf8iter fstreewalk rclconfig hldata unac mbox \
|
||||
circache wipedir mimetype pathut fileudi x11mon trqrstore ecrontab
|
||||
noinst_PROGRAMS = plaintorich textsplit fstreewalk rclconfig hldata unac mbox \
|
||||
circache wipedir mimetype fileudi x11mon trqrstore ecrontab
|
||||
|
||||
ecrontab_SOURCES = trecrontab.cpp
|
||||
ecrontab_LDADD = ../librecoll.la
|
||||
@ -62,9 +62,6 @@ mbox_LDADD = ../librecoll.la
|
||||
mimetype_SOURCES = trmimetype.cpp
|
||||
mimetype_LDADD = ../librecoll.la
|
||||
|
||||
pathut_SOURCES = trpathut.cpp
|
||||
pathut_LDADD = ../librecoll.la
|
||||
|
||||
rclconfig_SOURCES = trrclconfig.cpp
|
||||
rclconfig_LDADD = ../librecoll.la
|
||||
|
||||
@ -77,9 +74,6 @@ plaintorich_LDADD = ../librecoll.la
|
||||
unac_SOURCES = trunac.cpp
|
||||
unac_LDADD = ../librecoll.la
|
||||
|
||||
utf8iter_SOURCES = trutf8iter.cpp
|
||||
utf8iter_LDADD = ../librecoll.la
|
||||
|
||||
wipedir_SOURCES = trwipedir.cpp
|
||||
wipedir_LDADD = ../librecoll.la
|
||||
|
||||
|
||||
@ -39,6 +39,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#ifdef HAVE_SPAWN_H
|
||||
#ifndef __USE_GNU
|
||||
#define __USE_GNU
|
||||
@ -994,7 +995,8 @@ int ExecCmd::wait()
|
||||
LOGERR("ExecCmd::waitpid: returned -1 errno " << errno << "\n");
|
||||
status = -1;
|
||||
}
|
||||
LOGDEB("ExecCmd::wait: got status 0x" << (status) << "\n");
|
||||
LOGDEB("ExecCmd::wait: got status 0x" << std::hex << status << std::dec << ": " <<
|
||||
waitStatusAsString(status) << "\n");
|
||||
m->m_pid = -1;
|
||||
}
|
||||
// Let the ExecCmdRsrc cleanup, it will do the killing/waiting if needed
|
||||
@ -1043,6 +1045,23 @@ bool ExecCmd::backtick(const vector<string> cmd, string& out)
|
||||
return status == 0;
|
||||
}
|
||||
|
||||
std::string ExecCmd::waitStatusAsString(int wstatus)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
if (WIFEXITED(wstatus)) {
|
||||
oss << "Exit status: " << WEXITSTATUS(wstatus);
|
||||
} else {
|
||||
if (WIFSIGNALED(wstatus)) {
|
||||
oss << strsignal(WTERMSIG(wstatus)) << " ";
|
||||
}
|
||||
if (WCOREDUMP(wstatus)) {
|
||||
oss << "(core dumped)";
|
||||
}
|
||||
}
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
|
||||
/// ReExec class methods ///////////////////////////////////////////////////
|
||||
ReExec::ReExec(int argc, char *args[])
|
||||
{
|
||||
|
||||
@ -247,6 +247,8 @@ public:
|
||||
*/
|
||||
static bool backtick(const std::vector<std::string> cmd, std::string& out);
|
||||
|
||||
static std::string waitStatusAsString(int wstatus);
|
||||
|
||||
class Internal;
|
||||
private:
|
||||
Internal *m;
|
||||
|
||||
@ -1100,17 +1100,6 @@ bool ExecCmd::maybereap(int *status)
|
||||
}
|
||||
}
|
||||
|
||||
// Static
|
||||
bool ExecCmd::backtick(const vector<string> cmd, string& out)
|
||||
{
|
||||
vector<string>::const_iterator it = cmd.begin();
|
||||
it++;
|
||||
vector<string> args(it, cmd.end());
|
||||
ExecCmd mexec;
|
||||
int status = mexec.doexec(*cmd.begin(), args, 0, &out);
|
||||
return status == 0;
|
||||
}
|
||||
|
||||
int ExecCmd::doexec(const string &cmd, const vector<string>& args,
|
||||
const string *input, string *output)
|
||||
{
|
||||
@ -1159,3 +1148,23 @@ int ExecCmd::doexec(const string &cmd, const vector<string>& args,
|
||||
cleaner.inactivate();
|
||||
return wait();
|
||||
}
|
||||
|
||||
// Static
|
||||
bool ExecCmd::backtick(const vector<string> cmd, string& out)
|
||||
{
|
||||
vector<string>::const_iterator it = cmd.begin();
|
||||
it++;
|
||||
vector<string> args(it, cmd.end());
|
||||
ExecCmd mexec;
|
||||
int status = mexec.doexec(*cmd.begin(), args, 0, &out);
|
||||
return status == 0;
|
||||
}
|
||||
|
||||
// Static. Unimplemented on windows for now
|
||||
std::string ExecCmd::waitStatusAsString(int wstatus)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << std::hex << "0x" << wstatus << std::dec;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user