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.
◆ ExitThread()
| void SVSync::ExitThread |
( |
| ) |
|
|
static |
Signals a thread to exit.
Definition at line 113 of file svutil.cpp.
117 pthread_exit(
nullptr);
◆ StartProcess()
| void SVSync::StartProcess |
( |
const char * |
executable, |
|
|
const char * |
args |
|
) |
| |
|
static |
Starts a new process.
Definition at line 122 of file svutil.cpp.
124 proc.append(executable);
127 std::cout <<
"Starting " << proc << std::endl;
129 STARTUPINFO start_info;
130 PROCESS_INFORMATION proc_info;
131 GetStartupInfo(&start_info);
132 if (!CreateProcess(
nullptr, const_cast<char*>(proc.c_str()),
nullptr,
nullptr,
FALSE,
133 CREATE_NO_WINDOW | DETACHED_PROCESS,
nullptr,
nullptr,
134 &start_info, &proc_info))
143 prctl(PR_SET_PDEATHSIG, 2, 0, 0, 0);
145 char* mutable_args = strdup(args);
147 for (
int i = 0; mutable_args[i]; ++i) {
148 if (mutable_args[i] ==
' ') {
152 std::unique_ptr<char*[]> argv(
new char*[argc + 2]);
153 argv[0] = strdup(executable);
154 argv[1] = mutable_args;
156 bool inquote =
false;
157 for (
int i = 0; mutable_args[i]; ++i) {
158 if (!inquote && mutable_args[i] ==
' ') {
159 mutable_args[i] =
'\0';
160 argv[argc++] = mutable_args + i + 1;
161 }
else if (mutable_args[i] ==
'"') {
163 mutable_args[i] =
' ';
166 argv[argc] =
nullptr;
167 execvp(executable, argv.get());
◆ StartThread()
| void SVSync::StartThread |
( |
void *(*)(void *) |
func, |
|
|
void * |
arg |
|
) |
| |
|
static |
Create new thread.
Definition at line 89 of file svutil.cpp.
91 LPTHREAD_START_ROUTINE f = (LPTHREAD_START_ROUTINE)func;
102 pthread_attr_init(&attr);
103 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
104 pthread_create(&helper, &attr, func, arg);
The documentation for this class was generated from the following files: