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 105 of file svutil.cpp.
109 pthread_exit(
nullptr);
◆ StartProcess()
void SVSync::StartProcess |
( |
const char * |
executable, |
|
|
const char * |
args |
|
) |
| |
|
static |
Starts a new process.
Definition at line 114 of file svutil.cpp.
116 proc.append(executable);
119 std::cout <<
"Starting " << proc << std::endl;
121 STARTUPINFO start_info;
122 PROCESS_INFORMATION proc_info;
123 GetStartupInfo(&start_info);
124 if (!CreateProcess(
nullptr, const_cast<char*>(proc.c_str()),
nullptr,
nullptr,
FALSE,
125 CREATE_NO_WINDOW | DETACHED_PROCESS,
nullptr,
nullptr,
126 &start_info, &proc_info))
135 prctl(PR_SET_PDEATHSIG, 2, 0, 0, 0);
137 char* mutable_args = strdup(args);
139 for (
int i = 0; mutable_args[i]; ++i) {
140 if (mutable_args[i] ==
' ') {
144 std::unique_ptr<char*[]> argv(
new char*[argc + 2]);
145 argv[0] = strdup(executable);
146 argv[1] = mutable_args;
148 bool inquote =
false;
149 for (
int i = 0; mutable_args[i]; ++i) {
150 if (!inquote && mutable_args[i] ==
' ') {
151 mutable_args[i] =
'\0';
152 argv[argc++] = mutable_args + i + 1;
153 }
else if (mutable_args[i] ==
'"') {
155 mutable_args[i] =
' ';
158 argv[argc] =
nullptr;
159 execvp(executable, argv.get());
◆ StartThread()
void SVSync::StartThread |
( |
void *(*)(void *) |
func, |
|
|
void * |
arg |
|
) |
| |
|
static |
Create new thread.
Definition at line 81 of file svutil.cpp.
83 LPTHREAD_START_ROUTINE f = (LPTHREAD_START_ROUTINE)func;
94 pthread_attr_init(&attr);
95 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
96 pthread_create(&helper, &attr, func, arg);
The documentation for this class was generated from the following files: