git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Sixt <j.sixt@viscovery.net>
To: Dario Rodriguez <soft.d4rio@gmail.com>
Cc: Jeff King <peff@peff.net>,
	Ben Walton <bwalton@artsci.utoronto.ca>,
	git <git@vger.kernel.org>
Subject: Re: [PATCH/RFC] Fix for default pager
Date: Tue, 08 Jun 2010 20:59:55 +0200	[thread overview]
Message-ID: <4C0E932B.3010702@viscovery.net> (raw)
In-Reply-To: <AANLkTinZSuXJEXzpvEavYNLSyqUlx8qzWlrbtIH6q6fx@mail.gmail.com>

Am 08.06.2010 19:28, schrieb Dario Rodriguez:
> On Tue, Jun 8, 2010 at 12:56 PM, Johannes Sixt<j.sixt@viscovery.net>  wrote:
>> Am 08.06.2010 16:39, schrieb Dario Rodriguez:
>>>
>>> On Tue, Jun 8, 2010 at 11:17 AM, Johannes Sixt<j.sixt@viscovery.net>
>>>   wrote:
>>>>
>>>>   $ GIT_PAGER=/is/not/there git log
>>>>   $ echo $?
>>>>   141
>>>>
>>>> That's SIGPIPE, just as I would expect.
>>>
>>> As I said in the original thread...
>>>
>>> $ PAGER=/nothing/here ../git log
>>> $ echo $?
>>> 0
>>
>> That's no surprise with your toy repository: git-log has run to completion
>> (without overrunning the pipe buffer) before the pager process that it
>> forked can even execute its first instruction.
>>
>
> I cannot understand what's the point... I'm running git without
> installing it, but why do you say "toy repository"?...

Your repository has only 2 commits and its git log output is less than 
1kB, i.e., sufficiently small to fit in a pipe's buffer.

git log calls start_command to fork() the pager. The OS's scheduler does 
not run the newly forked process immediately; rather, git log goes on with 
its own business, writing output to the pipe that connects to the pager. 
Because your repository is so small, git log never has to wait that the 
pager drains the pipe. git log finally reaches exit(0). At this time, an 
atexit() handler (wait_for_pager()) finally calls finish_command() to wait 
for the pager.

This is the first time that the forked child process can run. Only now it 
turns out that the pager cannot be run. The child process closes the pipe 
and exits with an error, but it is too late: wait_for_pager() drops the 
error return code of finish_command() to the floor. The parent process 
(git log) can complete with the exit code that it was given earlier, 0.

Repeat your experiment with ./git log in git.git itself to see the difference.

-- Hannes

  reply	other threads:[~2010-06-08 19:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Installing on AIX fails>
2010-06-07 23:58 ` [PATCH/RFC] Fix for default pager Dario Rodriguez
2010-06-08  0:04   ` Ben Walton
2010-06-08  2:14     ` Dario Rodriguez
2010-06-08  5:35       ` Jeff King
2010-06-08 13:49         ` Dario Rodriguez
2010-06-08 14:17           ` Johannes Sixt
2010-06-08 14:39             ` Dario Rodriguez
2010-06-08 15:56               ` Johannes Sixt
2010-06-08 17:28                 ` Dario Rodriguez
2010-06-08 18:59                   ` Johannes Sixt [this message]
2010-06-08 20:44                     ` Dario Rodriguez
2010-06-08 21:33                       ` Andreas Ericsson
2010-06-09  9:08                         ` Tor Arntsen
2010-06-09  9:29                           ` Miles Bader
2010-06-10  8:29                           ` Jeff King
2010-06-10  8:48                             ` Tor Arntsen
2010-06-10  8:59                               ` Jeff King
2010-06-10  9:24                                 ` Tor Arntsen
2010-06-10 11:31                                   ` Dario Rodriguez
2010-06-10 14:55                                 ` Junio C Hamano
2010-06-15 16:11                                 ` Brandon Casey
2010-06-15 16:32                                   ` Tor Arntsen
2010-06-16  1:34                                   ` Nazri Ramliy
2010-06-16  6:28                                   ` Jeff King
2010-06-09 18:57                         ` Ævar Arnfjörð Bjarmason
2010-06-08  5:29   ` Jeff King
2010-06-08  6:12     ` Johannes Sixt
2010-06-08 12:24     ` Dario Rodriguez
2010-06-08 14:04       ` Erik Faye-Lund

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C0E932B.3010702@viscovery.net \
    --to=j.sixt@viscovery.net \
    --cc=bwalton@artsci.utoronto.ca \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=soft.d4rio@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).