The SVSync class provides functionality for Thread & Process Creation.
More...
#include <svutil.h>
The SVSync class provides functionality for Thread & Process Creation.
Definition at line 36 of file svutil.h.
| void SVSync::ExitThread |
( |
| ) |
|
|
static |
Signals a thread to exit.
Definition at line 104 of file svutil.cpp.
108 pthread_exit(
nullptr);
| void SVSync::StartProcess |
( |
const char * |
executable, |
|
|
const char * |
args |
|
) |
| |
|
static |
Starts a new process.
Definition at line 113 of file svutil.cpp.
115 proc.append(executable);
118 std::cout <<
"Starting " << proc << std::endl;
120 STARTUPINFO start_info;
121 PROCESS_INFORMATION proc_info;
122 GetStartupInfo(&start_info);
123 if (!CreateProcess(
nullptr, const_cast<char*>(proc.c_str()),
nullptr,
nullptr,
FALSE,
124 CREATE_NO_WINDOW | DETACHED_PROCESS,
nullptr,
nullptr,
125 &start_info, &proc_info))
134 prctl(PR_SET_PDEATHSIG, 2, 0, 0, 0);
136 char* mutable_args = strdup(args);
138 for (
int i = 0; mutable_args[i]; ++i) {
139 if (mutable_args[i] ==
' ') {
143 std::unique_ptr<char*[]> argv(
new char*[argc + 2]);
144 argv[0] = strdup(executable);
145 argv[1] = mutable_args;
147 bool inquote =
false;
148 for (
int i = 0; mutable_args[i]; ++i) {
149 if (!inquote && mutable_args[i] ==
' ') {
150 mutable_args[i] =
'\0';
151 argv[argc++] = mutable_args + i + 1;
152 }
else if (mutable_args[i] ==
'"') {
154 mutable_args[i] =
' ';
157 argv[argc] =
nullptr;
158 execvp(executable, argv.get());
| void SVSync::StartThread |
( |
void *(*)(void *) |
func, |
|
|
void * |
arg |
|
) |
| |
|
static |
Create new thread.
Definition at line 80 of file svutil.cpp.
82 LPTHREAD_START_ROUTINE f = (LPTHREAD_START_ROUTINE)func;
93 pthread_attr_init(&attr);
94 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
95 pthread_create(&helper, &attr, func, arg);
The documentation for this class was generated from the following files: