MCPcopy Create free account
hub / github.com/git/git / wait_or_whine

Function wait_or_whine

run-command.c:558–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

556}
557
558static int wait_or_whine(pid_t pid, const char *argv0, int in_signal)
559{
560 int status, code = -1;
561 pid_t waiting;
562 int failed_errno = 0;
563
564 while ((waiting = waitpid(pid, &status, 0)) < 0 && errno == EINTR)
565 ; /* nothing */
566
567 if (waiting < 0) {
568 failed_errno = errno;
569 if (!in_signal)
570 error_errno("waitpid for %s failed", argv0);
571 } else if (waiting != pid) {
572 if (!in_signal)
573 error("waitpid is confused (%s)", argv0);
574 } else if (WIFSIGNALED(status)) {
575 code = WTERMSIG(status);
576 if (!in_signal && code != SIGINT && code != SIGQUIT && code != SIGPIPE)
577 error("%s died of signal %d", argv0, code);
578 /*
579 * This return value is chosen so that code & 0xff
580 * mimics the exit code that a POSIX shell would report for
581 * a program that died from this signal.
582 */
583 code += 128;
584 } else if (WIFEXITED(status)) {
585 code = WEXITSTATUS(status);
586 } else {
587 if (!in_signal)
588 error("waitpid is confused (%s)", argv0);
589 }
590
591 if (!in_signal)
592 clear_child_for_cleanup(pid);
593
594 errno = failed_errno;
595 return code;
596}
597
598static void trace_add_env(struct strbuf *dst, const char *const *deltaenv)
599{

Callers 4

start_commandFunction · 0.85
finish_commandFunction · 0.85
finish_command_in_signalFunction · 0.85
finish_asyncFunction · 0.85

Calls 4

waitpidFunction · 0.85
error_errnoFunction · 0.85
errorFunction · 0.85
clear_child_for_cleanupFunction · 0.85

Tested by

no test coverage detected