MCPcopy Create free account
hub / github.com/boostorg/build / exec_wait

Function exec_wait

src/engine/execunix.cpp:455–590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

453 */
454
455void exec_wait()
456{
457 int finished = 0;
458
459 /* Process children that signaled. */
460 while ( !finished )
461 {
462 int i;
463 int select_timeout = globs.timeout;
464
465 /* Check for timeouts:
466 * - kill children that already timed out
467 * - decide how long until the next one times out
468 */
469 if ( globs.timeout > 0 )
470 {
471 struct tms buf;
472 clock_t const current = times( &buf );
473 for ( i = 0; i < globs.jobs; ++i )
474 if ( cmdtab[ i ].pid )
475 {
476 clock_t const consumed =
477 ( current - cmdtab[ i ].start_time ) / tps;
478 if ( consumed >= globs.timeout )
479 {
480 killpg( cmdtab[ i ].pid, SIGKILL );
481 cmdtab[ i ].exit_reason = EXIT_TIMEOUT;
482 }
483 else if ( globs.timeout - consumed < select_timeout )
484 select_timeout = globs.timeout - consumed;
485 }
486 }
487
488 /* select() will wait for I/O on a descriptor, a signal, or timeout. */
489 {
490 /* disable child termination signals while in select */
491 int ret;
492 int timeout;
493 sigset_t sigmask;
494 sigemptyset(&sigmask);
495 sigaddset(&sigmask, SIGCHLD);
496 sigprocmask(SIG_BLOCK, &sigmask, NULL);
497
498 /* If no timeout is specified, pass -1 (which means no timeout,
499 * wait indefinitely) to poll, to prevent busy-looping.
500 */
501 timeout = select_timeout? select_timeout * 1000 : -1;
502 while ( ( ret = poll( wait_fds, WAIT_FDS_SIZE, timeout ) ) == -1 )
503 if ( errno != EINTR )
504 break;
505 /* restore original signal mask by unblocking sigchld */
506 sigprocmask(SIG_UNBLOCK, &sigmask, NULL);
507 if ( ret <= 0 )
508 continue;
509 }
510
511 for ( i = 0; i < globs.jobs; ++i )
512 {

Callers

nothing calls this directly

Calls 6

read_descriptorFunction · 0.85
close_streamsFunction · 0.85
err_printfFunction · 0.85
timestamp_copyFunction · 0.85
timestamp_currentFunction · 0.85
interruptedFunction · 0.85

Tested by

no test coverage detected