1

I have a large pre-hook script I maintain to run checks on code, a build, run regression, and email a set of release notes. It has been working for a while, but some recent changes were made and now when we do a git push it results in a "Broken pipe" error. None of my changes appear to do anything that could cause a pipe error.

I tried running with GIT_TRACE and via strace and it doesn't really appear to be obvious to me what the issue is:

... Email Sent Successfully No errors! [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 125625 --- SIGCHLD (Child exited) @ 0 (0) --- write(4, "009c4a23dfcd66ae44d23435e45a2371"..., 156) = -1 EPIPE (Broken pipe) --- SIGPIPE (Broken pipe) @ 0 (0) --- +++ killed by SIGPIPE +++ 

2 Answers 2

2

A pre-push hook is required to read its standard input, which consists of a series of lines of the form described in the githooks documentation. That is, the input may be many lines long, not just one. Sometimes it may be just one line, but sometimes it will be more.

If your pre-push hook fails to read all of standard input, and Git writes a lot of input, Git's write to the now-closed pipe will result in an EPIPE error and a SIGPIPE signal. Since this is happening, you must not have read the entire input. To fix it, read the rest of the input.

Sign up to request clarification or add additional context in comments.

6 Comments

I added code to read the STDIN and it still fails. I read the STDIN at the beginning at end of the githook perl script. Could it be a problem that the script is perl and not a shell script? EDIT: these scripts worked last week and all of the sudden they stopped. I don't know if something else in my compute ENV changed. We're stuck on an old version of git (1.8.5.4)
Perl vs shell should not make a difference (nor that particular rather ancient Git version). If you can show your code, or simplify it to a short version that does not show anything proprietary or sensitive but still fails (i.e., produce a minimal reproducible example), that would help in diagnosing it.
I've not been able to reduce it with smaller snips of our code, and it is not something I can post due to the size of code and the proprietary nature of the code.
The EPIPE error itself requires that Git write some minimal number of bytes down the pipe beyond whatever you're already reading, so it's not surprising that it is hard to come up with a smaller reproducer. I don't write much perl myself but I'd probably tackle the problem by having the perl script read all of stdin first (eg into an array), extract the lines of interest, and only then do any work with them. (see eg stackoverflow.com/a/10762305/1256452)
I think I found the issue. SSH might be timing out while I am doing the build/regression. I noticed a message about the connection closed on the remote host in the middle of the regressions. I'll have to see if my host changed something that might be causing this.
|
0

Yes, the answer was indeed the ServerAliveInterval timer. The server closed and so it failed.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.