The SVSync class provides functionality for Thread & Process Creation.
More...
#include <svutil.h>
|
static void | StartProcess (const char *executable, const char *args) |
| Starts a new process. More...
|
|
The SVSync class provides functionality for Thread & Process Creation.
Definition at line 38 of file svutil.h.
◆ StartProcess()
void tesseract::SVSync::StartProcess |
( |
const char * |
executable, |
|
|
const char * |
args |
|
) |
| |
|
static |
Starts a new process.
Definition at line 67 of file svutil.cpp.
69 proc.append(executable);
72 std::cout <<
"Starting " << proc << std::endl;
74 STARTUPINFO start_info;
75 PROCESS_INFORMATION proc_info;
76 GetStartupInfo(&start_info);
77 if (!CreateProcess(
nullptr,
const_cast<char *
>(proc.c_str()),
nullptr,
78 nullptr,
FALSE, CREATE_NO_WINDOW | DETACHED_PROCESS,
79 nullptr,
nullptr, &start_info, &proc_info))
88 prctl(PR_SET_PDEATHSIG, 2, 0, 0, 0);
90 std::string mutable_args(args);
92 for (
auto ch : mutable_args) {
97 std::unique_ptr<char *[]> argv(
new char *[argc + 2]);
98 std::string argv0(executable);
100 argv[1] = &mutable_args[0];
102 bool inquote =
false;
103 for (
int i = 0; mutable_args[i]; ++i) {
104 if (!inquote && mutable_args[i] ==
' ') {
105 mutable_args[i] =
'\0';
106 argv[argc++] = &mutable_args[i + 1];
107 }
else if (mutable_args[i] ==
'"') {
109 mutable_args[i] =
' ';
112 argv[argc] =
nullptr;
113 execvp(executable, argv.get());
The documentation for this class was generated from the following files: