@@ -256,7 +256,7 @@ static void ProcessHandler(void)
256
256
257
257
struct iovec io;
258
258
io.iov_base = &length;
259
- io.iov_len = sizeof (size_t );
259
+ io.iov_len = sizeof (length );
260
260
261
261
msg.msg_iov = &io;
262
262
msg.msg_iovlen = 1 ;
@@ -267,17 +267,11 @@ static void ProcessHandler(void)
267
267
268
268
int rc = recvmsg (l_ProcessControlFD, &msg, 0 );
269
269
270
- if (rc < 0 && (errno == EINTR || errno == EAGAIN))
271
- continue ;
272
-
273
- if (rc < 0 ) {
274
- BOOST_THROW_EXCEPTION (posix_error ()
275
- << boost::errinfo_api_function (" recvmsg" )
276
- << boost::errinfo_errno (errno));
277
- }
270
+ if (rc <= 0 ) {
271
+ if (rc < 0 && (errno == EINTR || errno == EAGAIN))
272
+ continue ;
278
273
279
- if (length > 1024 * 1024 * 1024 ) {
280
- BOOST_THROW_EXCEPTION (std::runtime_error (" invalid message length" ));
274
+ break ;
281
275
}
282
276
283
277
char *mbuf = new char [length];
@@ -286,15 +280,13 @@ static void ProcessHandler(void)
286
280
while (count < length) {
287
281
rc = recv (l_ProcessControlFD, mbuf + count, length - count, 0 );
288
282
289
- if (rc < 0 ) {
290
- if (errno == EINTR || errno == EAGAIN)
291
- continue ;
283
+ if (rc <= 0 ) {
284
+ if (rc < 0 && ( errno == EINTR || errno == EAGAIN) )
285
+ continue ;
292
286
293
287
delete [] mbuf;
294
288
295
- BOOST_THROW_EXCEPTION (posix_error ()
296
- << boost::errinfo_api_function (" recv" )
297
- << boost::errinfo_errno (errno));
289
+ _exit (0 );
298
290
}
299
291
300
292
count += rc;
@@ -391,7 +383,7 @@ static pid_t ProcessSpawn(const std::vector<String>& arguments, const Dictionary
391
383
392
384
struct iovec io;
393
385
io.iov_base = &length;
394
- io.iov_len = sizeof (size_t );
386
+ io.iov_len = sizeof (length );
395
387
396
388
msg.msg_iov = &io;
397
389
msg.msg_iovlen = 1 ;
@@ -409,14 +401,12 @@ static pid_t ProcessSpawn(const std::vector<String>& arguments, const Dictionary
409
401
410
402
msg.msg_controllen = cmsg->cmsg_len ;
411
403
404
+ send_message:
412
405
while (sendmsg (l_ProcessControlFD, &msg, 0 ) < 0 )
413
406
StartSpawnProcessHelper ();
414
407
415
- if (send (l_ProcessControlFD, jrequest.CStr (), jrequest.GetLength (), 0 ) < 0 ) {
416
- BOOST_THROW_EXCEPTION (posix_error ()
417
- << boost::errinfo_api_function (" send" )
418
- << boost::errinfo_errno (errno));
419
- }
408
+ if (send (l_ProcessControlFD, jrequest.CStr (), jrequest.GetLength (), 0 ) < 0 )
409
+ goto send_message;
420
410
421
411
char buf[4096 ];
422
412
@@ -443,14 +433,12 @@ static int ProcessKill(pid_t pid, int signum)
443
433
444
434
boost::mutex::scoped_lock lock (l_ProcessControlMutex);
445
435
446
- while (send (l_ProcessControlFD, &length, sizeof (size_t ), 0 ) < 0 )
436
+ send_message:
437
+ while (send (l_ProcessControlFD, &length, sizeof (length), 0 ) < 0 )
447
438
StartSpawnProcessHelper ();
448
439
449
- if (send (l_ProcessControlFD, jrequest.CStr (), jrequest.GetLength (), 0 ) < 0 ) {
450
- BOOST_THROW_EXCEPTION (posix_error ()
451
- << boost::errinfo_api_function (" send" )
452
- << boost::errinfo_errno (errno));
453
- }
440
+ if (send (l_ProcessControlFD, jrequest.CStr (), jrequest.GetLength (), 0 ) < 0 )
441
+ goto send_message;
454
442
455
443
char buf[4096 ];
456
444
@@ -476,14 +464,12 @@ static int ProcessWaitPID(pid_t pid, int *status)
476
464
477
465
boost::mutex::scoped_lock lock (l_ProcessControlMutex);
478
466
479
- while (send (l_ProcessControlFD, &length, sizeof (size_t ), 0 ) < 0 )
467
+ send_message:
468
+ while (send (l_ProcessControlFD, &length, sizeof (length), 0 ) < 0 )
480
469
StartSpawnProcessHelper ();
481
470
482
- if (send (l_ProcessControlFD, jrequest.CStr (), jrequest.GetLength (), 0 ) < 0 ) {
483
- BOOST_THROW_EXCEPTION (posix_error ()
484
- << boost::errinfo_api_function (" send" )
485
- << boost::errinfo_errno (errno));
486
- }
471
+ if (send (l_ProcessControlFD, jrequest.CStr (), jrequest.GetLength (), 0 ) < 0 )
472
+ goto send_message;
487
473
488
474
char buf[4096 ];
489
475
0 commit comments