MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / spawnProcess

Function spawnProcess

Common/helper_multiprocess.cpp:121–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121int spawnProcess(Process *process, const char *app, char *const *args) {
122#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
123 STARTUPINFO si = {0};
124 BOOL status;
125 size_t arglen = 0;
126 size_t argIdx = 0;
127 std::string arg_string;
128 memset(process, 0, sizeof(*process));
129
130 while (*args) {
131 arg_string.append(*args).append(1, ' ');
132 args++;
133 }
134
135 status = CreateProcess(app, LPSTR(arg_string.c_str()), NULL, NULL, FALSE, 0,
136 NULL, NULL, &si, process);
137
138 return status ? 0 : GetLastError();
139#else
140 *process = fork();
141 if (*process == 0) {
142 if (0 > execvp(app, args)) {
143 return errno;
144 }
145 } else if (*process < 0) {
146 return errno;
147 }
148 return 0;
149#endif
150}
151
152int waitProcess(Process *process) {
153#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)

Callers 1

parentProcessFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected