- new OsProcess::execSystem() method
This commit is contained in:
parent
f70f872d6a
commit
5232d33f6e
|
|
@ -212,6 +212,11 @@ std::string OsProcess::execCommand(const std::string& cmd)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int OsProcess::execSystem(const std::string& cmd)
|
||||||
|
{
|
||||||
|
return system(cmd.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
|
|
@ -321,7 +326,7 @@ void OsProcess::killByPid(pid_t pid)
|
||||||
{
|
{
|
||||||
if (pid <= 0)
|
if (pid <= 0)
|
||||||
return;
|
return;
|
||||||
execCommand("kill -9 " + std::to_string(pid));
|
execSystem("kill " + std::to_string(pid));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ class OsProcess
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::string execCommand(const std::string& cmdline);
|
static std::string execCommand(const std::string& cmdline);
|
||||||
|
static int execSystem(const std::string& cmdline);
|
||||||
static std::shared_ptr<std::thread> asyncExecCommand(const std::string& cmdline,
|
static std::shared_ptr<std::thread> asyncExecCommand(const std::string& cmdline,
|
||||||
std::function<void(const std::string& line)> line_callback,
|
std::function<void(const std::string& line)> line_callback,
|
||||||
std::function<void(const std::string& reason)> finished_callback,
|
std::function<void(const std::string& reason)> finished_callback,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue