<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/run-command.c, branch v1.7.9.7</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://www.git.shady.money/git/atom?h=v1.7.9.7</id>
<link rel='self' href='https://www.git.shady.money/git/atom?h=v1.7.9.7'/>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/'/>
<updated>2012-01-08T23:07:20Z</updated>
<entry>
<title>dashed externals: kill children on exit</title>
<updated>2012-01-08T23:07:20Z</updated>
<author>
<name>Clemens Buchacher</name>
<email>drizzd@aon.at</email>
</author>
<published>2012-01-08T20:41:09Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=10c6cddd928b24ac6030a172c6c7b46efb32aedc'/>
<id>urn:sha1:10c6cddd928b24ac6030a172c6c7b46efb32aedc</id>
<content type='text'>
Several git commands are so-called dashed externals, that is commands
executed as a child process of the git wrapper command. If the git
wrapper is killed by a signal, the child process will continue to run.
This is different from internal commands, which always die with the git
wrapper command.

Enable the recently introduced cleanup mechanism for child processes in
order to make dashed externals act more in line with internal commands.

Signed-off-by: Clemens Buchacher &lt;drizzd@aon.at&gt;
Acked-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>run-command: optionally kill children on exit</title>
<updated>2012-01-08T23:06:35Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2012-01-07T11:42:43Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=afe19ff7b55129d988e421ae1e0df4ec9659787a'/>
<id>urn:sha1:afe19ff7b55129d988e421ae1e0df4ec9659787a</id>
<content type='text'>
When we spawn a helper process, it should generally be done
and finish_command called before we exit. However, if we
exit abnormally due to an early return or a signal, the
helper may continue to run in our absence.

In the best case, this may simply be wasted CPU cycles or a
few stray messages on a terminal. But it could also mean a
process that the user thought was aborted continues to run
to completion (e.g., a push's pack-objects helper will
complete the push, even though you killed the push process).

This patch provides infrastructure for run-command to keep
track of PIDs to be killed, and clean them on signal
reception or input, just as we do with tempfiles. PIDs can
be added in two ways:

  1. If NO_PTHREADS is defined, async helper processes are
     automatically marked. By definition this code must be
     ready to die when the parent dies, since it may be
     implemented as a thread of the parent process.

  2. If the run-command caller specifies the "clean_on_exit"
     option. This is not the default, as there are cases
     where it is OK for the child to outlive us (e.g., when
     spawning a pager).

PIDs are cleared from the kill-list automatically during
wait_or_whine, which is called from finish_command and
finish_async.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Clemens Buchacher &lt;drizzd@aon.at&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/argv-array'</title>
<updated>2011-10-05T19:36:24Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2011-10-05T19:36:24Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=7a95d1be03d3fdd571bd36ea5b8bc5c59b063249'/>
<id>urn:sha1:7a95d1be03d3fdd571bd36ea5b8bc5c59b063249</id>
<content type='text'>
* jk/argv-array:
  run_hook: use argv_array API
  checkout: use argv_array API
  bisect: use argv_array API
  quote: provide sq_dequote_to_argv_array
  refactor argv_array into generic code
  quote.h: fix bogus comment
  add sha1_array API docs
</content>
</entry>
<entry>
<title>run_hook: use argv_array API</title>
<updated>2011-09-14T18:57:33Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2011-09-13T21:58:25Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=5d40a179855a39ae9e8ac22e1874720f2b98a91c'/>
<id>urn:sha1:5d40a179855a39ae9e8ac22e1874720f2b98a91c</id>
<content type='text'>
This was a pretty straightforward use, so it really doesn't
save that many lines. Still, perhaps it's a little bit more
readable.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>notice error exit from pager</title>
<updated>2011-08-01T23:21:55Z</updated>
<author>
<name>Clemens Buchacher</name>
<email>drizzd@aon.at</email>
</author>
<published>2011-08-01T17:59:21Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=fc1b56f054a79400c4e72cb1aab97ba2605cbd83'/>
<id>urn:sha1:fc1b56f054a79400c4e72cb1aab97ba2605cbd83</id>
<content type='text'>
If the pager fails to run, git produces no output, e.g.:

 $ GIT_PAGER=not-a-command git log

The error reporting fails for two reasons:

 (1) start_command: There is a mechanism that detects errors during
     execvp introduced in 2b541bf8 (start_command: detect execvp
     failures early). The child writes one byte to a pipe only if
     execvp fails.  The parent waits for either EOF, when the
     successful execvp automatically closes the pipe (see
     FD_CLOEXEC in fcntl(1)), or it reads a single byte, in which
     case it knows that the execvp failed. This mechanism is
     incompatible with the workaround introduced in 35ce8622
     (pager: Work around window resizing bug in 'less'), which
     waits for input from the parent before the exec. Since both
     the parent and the child are waiting for input from each
     other, that would result in a deadlock. In order to avoid
     that, the mechanism is disabled by closing the child_notifier
     file descriptor.

 (2) finish_command: The parent correctly detects the 127 exit
     status from the child, but the error output goes nowhere,
     since by that time it is already being redirected to the
     child.

No simple solution for (1) comes to mind.

Number (2) can be solved by not sending error output to the pager.
Not redirecting error output to the pager can result in the pager
overwriting error output with standard output, however.

Since there is no reliable way to handle error reporting in the
parent, produce the output in the child instead.

Signed-off-by: Clemens Buchacher &lt;drizzd@aon.at&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>error_routine: use parent's stderr if exec fails</title>
<updated>2011-08-01T01:27:07Z</updated>
<author>
<name>Clemens Buchacher</name>
<email>drizzd@aon.at</email>
</author>
<published>2011-07-27T21:32:34Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=3bc4181fde899e02aff89f7c0a47f18d37311cb3'/>
<id>urn:sha1:3bc4181fde899e02aff89f7c0a47f18d37311cb3</id>
<content type='text'>
The new process's error output may be redirected elsewhere, but if
the exec fails, output should still go to the parent's stderr. This
has already been done for the die_routine. Do the same for
error_routine.

Signed-off-by: Clemens Buchacher &lt;drizzd@aon.at&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>run-command: handle short writes and EINTR in die_child</title>
<updated>2011-04-20T17:09:26Z</updated>
<author>
<name>Jonathan Nieder</name>
<email>jrnieder@gmail.com</email>
</author>
<published>2011-04-20T10:40:05Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=a111eb7808bfdb90286e54b9ccdaea4f3bec3102'/>
<id>urn:sha1:a111eb7808bfdb90286e54b9ccdaea4f3bec3102</id>
<content type='text'>
If start_command fails after forking and before exec finishes, there
is not much use in noticing an I/O error on top of that.
finish_command will notice that the child exited with nonzero status
anyway.  So as noted in v1.7.0.3~20^2 (run-command.c: fix build
warnings on Ubuntu, 2010-01-30) and v1.7.5-rc0~29^2 (2011-03-16), it
is safe to ignore errors from write in this codepath.

Even so, the result from write contains useful information: it tells
us if the write was cancelled by a signal (EINTR) or was only
partially completed (e.g., when writing to an almost-full pipe).
Let's use write_in_full to loop until the desired number of bytes have
been written (still ignoring errors if that fails).

As a happy side effect, the assignment to a dummy variable to appease
gcc -D_FORTIFY_SOURCE is no longer needed.  xwrite and write_in_full
check the return value from write(2).

Noticed with gcc -Wunused-but-set-variable.

Signed-off-by: Jonathan Nieder &lt;jrnieder@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Revert "run-command: prettify -D_FORTIFY_SOURCE workaround"</title>
<updated>2011-04-18T21:14:53Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2011-04-18T21:14:53Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=60e199c4d577514ed810b4ed0b6072fb3dbab903'/>
<id>urn:sha1:60e199c4d577514ed810b4ed0b6072fb3dbab903</id>
<content type='text'>
This reverts commit ebec842773932e6f853acac70c80f84209b5f83e, which
somehow mistakenly thought that any non-zero return from write(2) is
an error.
</content>
</entry>
<entry>
<title>run-command: prettify -D_FORTIFY_SOURCE workaround</title>
<updated>2011-03-17T22:32:43Z</updated>
<author>
<name>Jonathan Nieder</name>
<email>jrnieder@gmail.com</email>
</author>
<published>2011-03-16T07:32:39Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=ebec842773932e6f853acac70c80f84209b5f83e'/>
<id>urn:sha1:ebec842773932e6f853acac70c80f84209b5f83e</id>
<content type='text'>
Current gcc + glibc with -D_FORTIFY_SOURCE try very aggressively to
protect against a programming style which uses write(...) without
checking the return value for errors.  Even the usual hint of casting
to (void) does not suppress the warning.

Sometimes when there is an output error, especially right before exit,
there really is nothing to be done.  The obvious solution, adopted in
v1.7.0.3~20^2 (run-command.c: fix build warnings on Ubuntu,
2010-01-30), is to save the return value to a dummy variable:

	ssize_t dummy;
	dummy = write(...);

But that (1) is ugly and (2) triggers -Wunused-but-set-variable
warnings with gcc-4.6 -Wall, so we are not much better off than when
we started.

Instead, use an "if" statement with an empty body to make the intent
clear.

	if (write(...))
		; /* yes, yes, there was an error. */

Signed-off-by: Jonathan Nieder &lt;jrnieder@gmail.com&gt;
Improved-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>start_command: flush buffers in the WIN32 code path as well</title>
<updated>2011-02-07T22:18:56Z</updated>
<author>
<name>Johannes Sixt</name>
<email>j6t@kdbg.org</email>
</author>
<published>2011-02-04T08:41:58Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=13af8cbd6af3f572a5c6c2fb7adc8fc7c408a3e2'/>
<id>urn:sha1:13af8cbd6af3f572a5c6c2fb7adc8fc7c408a3e2</id>
<content type='text'>
The POSIX code path did The Right Thing already, but we have to do the same
on Windows.

This bug caused failures in t5526-fetch-submodules, where the output of
'git fetch --recurse-submodules' was in the wrong order.

Debugged-by: Johannes Schindelin &lt;Johannes.Schindelin@gmx.de&gt;
Signed-off-by: Johannes Sixt &lt;j6t@kdbg.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
