Tuesday, July 12, 2016

git log exit code 141?

Something's that been bugging me for a while now is that when I do a `git log` command and quit before scrolling through all the output, my terminal prompt shows my last command (the git log) exited non-zero with status code 141.

I have git configured to use `less -+S` as the pager.

The answer turns out to be really straightforward, but took me a little bit of internet searching. I am capturing the learning here to save my future self the research and possibly anyone else typing the exact same thing into Google that I did ;-)

The explanation:

  • Git pipes the logs into less
  • I quit the less process, which sends a SIGPIPE signal (13) to the underlying git process streaming the logs
  • git catches the interrupt and exits prematurely and per POSIX convention returns 128 + the SIGPIPE status ==> 141 to indicate that it was terminated by signal 13
The background:
  1. http://stackoverflow.com/questions/19120263/why-exit-code-141-with-grep-q
  2. http://www.pixelbeat.org/programming/sigpipe_handling.html
  3. http://unix.stackexchange.com/questions/99112/default-exit-code-when-process-is-terminated/99134#99134


  1. Is there any way to fix the exit code so that it is 0?

    1. Yes, change your git pager configuration to just `less`

    2. I have tried setting core.pager to 'less' as well as removing all color-related env vars, and I continue to get error 141 when I quit 'git log'. Any more ideas?

    3. I set "pager = cat | less" to force all of stdin to be read before passing it to less


  2. This bug can be seen often. Hope you were able to resolve this issue.

    Please click on the link below.
    Best Advanced Excel classes in Bangalore

  3. Nice post keep do posting The Info was too good, for more information regarding the technology Click
    Amazon web Services Training
    Professional Salesforce CRM Training
    Salesforce Online Training in Bangalore

  4. myTectra Placement Portal is a Web based portal brings Potentials Employers and myTectra Candidates on a common platform for placement assistance

  5. When such problems arise, I try to immediately solve it because in the future it can lead to serious malfunctions.

  6. Greetings! I just wanted to thank you for the published entry! You have helped us too much! We are glad we have found this source here.

  7. This comment has been removed by the author.

  8. This comment has been removed by the author.

  9. Nice post I have been searching for a useful post like this on salesforce course details, it is highly helpful for me and I have a great expereince with this
    Salesforce Training  which is a best institute for career building program.

  10. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    workday studio online training
    best workday studio online training
    top workday studio online training

  11. Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. erek erek

  12. They can't figure out why their co-worker isn't pulling his or her own weight and why the sales manager isn't doing anything about it. Salesforce training in Chennai