MCPcopy Create free account
hub / github.com/Icinga/icinga2 / ProcessHandler

Function ProcessHandler

lib/base/process.cpp:257–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257static void ProcessHandler()
258{
259 sigset_t mask;
260 sigfillset(&mask);
261 sigprocmask(SIG_SETMASK, &mask, nullptr);
262
263 Utility::CloseAllFDs({0, 1, 2, l_ProcessControlFD});
264
265 for (;;) {
266 size_t length;
267
268 struct msghdr msg;
269 memset(&msg, 0, sizeof(msg));
270
271 struct iovec io;
272 io.iov_base = &length;
273 io.iov_len = sizeof(length);
274
275 msg.msg_iov = &io;
276 msg.msg_iovlen = 1;
277
278 char cbuf[4096];
279 msg.msg_control = cbuf;
280 msg.msg_controllen = sizeof(cbuf);
281
282 int rc = recvmsg(l_ProcessControlFD, &msg, 0);
283
284 if (rc <= 0) {
285 if (rc < 0 && (errno == EINTR || errno == EAGAIN))
286 continue;
287
288 break;
289 }
290
291 auto *mbuf = new char[length];
292
293 size_t count = 0;
294 while (count < length) {
295 rc = recv(l_ProcessControlFD, mbuf + count, length - count, 0);
296
297 if (rc <= 0) {
298 if (rc < 0 && (errno == EINTR || errno == EAGAIN))
299 continue;
300
301 delete [] mbuf;
302
303 _exit(0);
304 }
305
306 count += rc;
307
308 if (rc == 0)
309 break;
310 }
311
312 String jrequest = String(mbuf, mbuf + count);
313
314 delete [] mbuf;

Callers 1

StartSpawnProcessHelperFunction · 0.85

Calls 8

ProcessSpawnImplFunction · 0.85
ProcessWaitPIDImplFunction · 0.85
ProcessKillImplFunction · 0.85
posix_errorClass · 0.85
CStrMethod · 0.80
StringClass · 0.70
GetMethod · 0.45
GetLengthMethod · 0.45

Tested by

no test coverage detected