Skip to content

Commit

Permalink
Fix dependency generators sometimes dying with SIGPIPE
Browse files Browse the repository at this point in the history
If a dependency generator dies while we're still writing to its stdin,
it causes us to die rather randomly. Typically happens with fake
dependency generators that don't actually bother reading their input
and/or write anything back. This is almost certainly the ghost failure
we've occasionally seen in the test-suite too (rpm-software-management#2470).

Resurrect the explicit SIG_IGN that got removed apparently in commit
375a6b5. The matter was further
confused by NSPR (which we once relied on) always setting SIGPIPE
to SIG_IGN.

Suggested-by: Michael Schroeder <mls@suse.de>

Fixes: rpm-software-management#2949
  • Loading branch information
pmatilai committed Mar 11, 2024
1 parent fc83793 commit 3972022
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions build/rpmfc.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ static int getOutputFrom(ARGV_t argv,
return -1;
}

void *oldhandler = signal(SIGPIPE, SIG_IGN);

child = fork();
if (child < 0) {
rpmlog(RPMLOG_ERR, _("Couldn't fork %s: %s\n"),
Expand Down Expand Up @@ -416,6 +418,8 @@ static int getOutputFrom(ARGV_t argv,
reaped = waitpid(child, &status, 0);
} while (reaped == -1 && errno == EINTR);

signal(SIGPIPE, oldhandler);

/*
* It's not allowed to call WIFEXITED or WEXITSTATUS if waitpid return -1.
* Note, all bits set, since -1 == 0xFFFFFFFF
Expand Down

0 comments on commit 3972022

Please sign in to comment.