git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How to handle terminal detection in a daemon calling git?

From
Junio C Hamano <gitster@pobox.com>
Date
May 31, 2012, 06:22 UTC
Message-ID
<7vaa0o98e5.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120531012908.GD5488@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 21 quoted lines
> On Wed, May 30, 2012 at 04:16:47PM -0500, Travis P wrote:
>
>> I've got a script that runs in the background without a terminal.
>> It actually does have STDOUT and STDERR set to a rotating log file.
>> 
>> When it runs:
>>   /bin/sh -c 'cd /to/my/wc; git pull --ff-only'
>> the git command fails (rc 32768).
>> 
>> When it runs
>>  /bin/sh -c 'cd /to/my/wc; git pull --ff-only > /to/a/file 2>&1'
>> 
>> or even
>>  /bin/sh -c 'cd /to/my/wc; git pull --ff-only | cat'
>> 
>> then all is well.  The command succeeds (rc 0, and I see the expected
>> results).
>
> If your stdout and stderr are not a terminal in the first place (you say
> they go to a rotating log file), then that should not be making a
> difference. Are they connected by a pty or something odd?
A more likely failure case is when fd 0, 1 and 2 are _closed_.

I vaguely recall we once saw a failure report for that particular case, and then audited the code several years ago, but I do not offhand know if we have regressed over time.

Previous: Jeff KingNext: Travis P
Message 3 of 9 in “How to handle terminal detection in a daemon calling git?”
  1. Travis PMay 30, 2012
  2. Jeff KingMay 31, 2012
  3. Junio C HamanoMay 31, 2012
  4. Travis PMay 31, 2012
  5. Jeff KingJun 1, 2012
  6. TravisJun 1, 2012
  7. Jeff KingJun 2, 2012
  8. Travis PMay 31, 2012
  9. Sitaram ChamartyMay 31, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.