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 36 of file svutil.h.
◆ StartProcess()
void SVSync::StartProcess |
( |
const char * |
executable, |
|
|
const char * |
args |
|
) |
| |
|
static |
Starts a new process.
Definition at line 60 of file svutil.cpp.
62 proc.append(executable);
65 std::cout <<
"Starting " << proc << std::endl;
67 STARTUPINFO start_info;
68 PROCESS_INFORMATION proc_info;
69 GetStartupInfo(&start_info);
70 if (!CreateProcess(
nullptr, const_cast<char*>(proc.c_str()),
nullptr,
nullptr,
FALSE,
71 CREATE_NO_WINDOW | DETACHED_PROCESS,
nullptr,
nullptr,
72 &start_info, &proc_info))
81 prctl(PR_SET_PDEATHSIG, 2, 0, 0, 0);
83 char* mutable_args = strdup(args);
85 for (
int i = 0; mutable_args[i]; ++i) {
86 if (mutable_args[i] ==
' ') {
90 std::unique_ptr<char*[]> argv(
new char*[argc + 2]);
91 argv[0] = strdup(executable);
92 argv[1] = mutable_args;
95 for (
int i = 0; mutable_args[i]; ++i) {
96 if (!inquote && mutable_args[i] ==
' ') {
97 mutable_args[i] =
'\0';
98 argv[argc++] = mutable_args + i + 1;
99 }
else if (mutable_args[i] ==
'"') {
101 mutable_args[i] =
' ';
104 argv[argc] =
nullptr;
105 execvp(executable, argv.get());
The documentation for this class was generated from the following files: