<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/run-command.c, branch v2.4.9</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.4.9</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.4.9'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2015-03-25T19:54:27Z</updated>
<entry>
<title>Merge branch 'jk/run-command-capture'</title>
<updated>2015-03-25T19:54:27Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2015-03-25T19:54:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ea1fd481b4e689f143142662a82fb62c9b2efb65'/>
<id>urn:sha1:ea1fd481b4e689f143142662a82fb62c9b2efb65</id>
<content type='text'>
The run-command interface was easy to abuse and make a pipe for us
to read from the process, wait for the process to finish and then
attempt to read its output, which is a pattern that lead to a
deadlock.  Fix such uses by introducing a helper to do this
correctly (i.e. we need to read first and then wait the process to
finish) and also add code to prevent such abuse in the run-command
helper.

* jk/run-command-capture:
  run-command: forbid using run_command with piped output
  trailer: use capture_command
  submodule: use capture_command
  wt-status: use capture_command
  run-command: introduce capture_command helper
  wt_status: fix signedness mismatch in strbuf_read call
  wt-status: don't flush before running "submodule status"
</content>
</entry>
<entry>
<title>run-command: forbid using run_command with piped output</title>
<updated>2015-03-23T04:39:22Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2015-03-23T03:54:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c29b3962af3df80a43fab4ead4875bd2ca275e4c'/>
<id>urn:sha1:c29b3962af3df80a43fab4ead4875bd2ca275e4c</id>
<content type='text'>
Because run_command both spawns and wait()s for the command
before returning control to the caller, any reads from the
pipes we open must necessarily happen after wait() returns.
This can lead to deadlock, as the child process may block
on writing to us while we are blocked waiting for it to
exit.

Worse, it only happens when the child fills the pipe
buffer, which means that the problem may come and go
depending on the platform and the size of the output
produced by the child.

Let's detect and flag this dangerous construct so that we
can catch potential bugs early in the test suite rather than
having them happen in the field.

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>run-command: introduce capture_command helper</title>
<updated>2015-03-23T04:38:31Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2015-03-23T03:53:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=911ec99b688fc4d5673a0fc8984b22ff2251e490'/>
<id>urn:sha1:911ec99b688fc4d5673a0fc8984b22ff2251e490</id>
<content type='text'>
Something as simple as reading the stdout from a command
turns out to be rather hard to do right. Doing:

  cmd.out = -1;
  run_command(&amp;cmd);
  strbuf_read(&amp;buf, cmd.out, 0);

can result in deadlock if the child process produces a large
amount of output. What happens is:

  1. The parent spawns the child with its stdout connected
     to a pipe, of which the parent is the sole reader.

  2. The parent calls wait(), blocking until the child exits.

  3. The child writes to stdout. If it writes more data than
     the OS pipe buffer can hold, the write() call will
     block.

This is a deadlock; the parent is waiting for the child to
exit, and the child is waiting for the parent to call
read().

So we might try instead:

  start_command(&amp;cmd);
  strbuf_read(&amp;buf, cmd.out, 0);
  finish_command(&amp;cmd);

But that is not quite right either. We are examining cmd.out
and running finish_command whether start_command succeeded
or not, which is wrong. Moreover, these snippets do not do
any error handling. If our read() fails, we must make sure
to still call finish_command (to reap the child process).
And both snippets failed to close the cmd.out descriptor,
which they must do (provided start_command succeeded).

Let's introduce a run-command helper that can make this a
bit simpler for callers to get right.

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>git-compat-util.h: move SHELL_PATH default into header</title>
<updated>2015-03-10T22:11:24Z</updated>
<author>
<name>Kyle J. McKay</name>
<email>mackyle@gmail.com</email>
</author>
<published>2015-03-08T05:07:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1b56cdf901f6e6a73d0edadf56afb1c878c7622a'/>
<id>urn:sha1:1b56cdf901f6e6a73d0edadf56afb1c878c7622a</id>
<content type='text'>
If SHELL_PATH is not defined we use "/bin/sh".  However,
run-command.c is not the only file that needs to use
the default value so move it into a common header.

Signed-off-by: Kyle J. McKay &lt;mackyle@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jc/hook-cleanup'</title>
<updated>2014-12-22T20:27:10Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-12-22T20:27:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=77a801d23788991a752a19a45a7474fa8b707082'/>
<id>urn:sha1:77a801d23788991a752a19a45a7474fa8b707082</id>
<content type='text'>
Remove unused code.

* jc/hook-cleanup:
  run-command.c: retire unused run_hook_with_custom_index()
</content>
</entry>
<entry>
<title>run-command.c: retire unused run_hook_with_custom_index()</title>
<updated>2014-12-01T16:39:43Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-12-01T16:39:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=814dd8e07890c442480c5aacff9a7f1d10beb062'/>
<id>urn:sha1:814dd8e07890c442480c5aacff9a7f1d10beb062</id>
<content type='text'>
This was originally meant to be used to rewrite run_commit_hook()
that only special cases the GIT_INDEX_FILE environment, but the
run_hook_ve() refactoring done earlier made the implementation of
run_commit_hook() thin and clean enough.

Nobody uses this, so retire it as an unfinished clean-up made
unnecessary.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>run-command: use void to declare that functions take no parameters</title>
<updated>2014-11-10T22:43:19Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2014-11-10T21:17:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6066a7eac4b2bcdb86971783b583e4e408b32e81'/>
<id>urn:sha1:6066a7eac4b2bcdb86971783b583e4e408b32e81</id>
<content type='text'>
Explicitly declare that git_atexit_dispatch() and git_atexit_clear()
take no parameters instead of leaving their parameter list empty and
thus unspecified.

Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'eb/no-pthreads'</title>
<updated>2014-10-24T21:59:10Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-10-24T21:59:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=e4da4fbe0eea55c26f042f76df58bfc529b46ae0'/>
<id>urn:sha1:e4da4fbe0eea55c26f042f76df58bfc529b46ae0</id>
<content type='text'>
Allow us build with NO_PTHREADS=NoThanks compilation option.

* eb/no-pthreads:
  Handle atexit list internaly for unthreaded builds
  pack-objects: set number of threads before checking and warning
  index-pack: fix compilation with NO_PTHREADS
</content>
</entry>
<entry>
<title>Handle atexit list internaly for unthreaded builds</title>
<updated>2014-10-19T22:38:30Z</updated>
<author>
<name>Etienne Buira</name>
<email>etienne.buira@gmail.com</email>
</author>
<published>2014-10-18T12:31:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0f4b6db3baeff8de53769b38f439408abd5a42f7'/>
<id>urn:sha1:0f4b6db3baeff8de53769b38f439408abd5a42f7</id>
<content type='text'>
Wrap atexit()s calls on unthreaded builds to handle callback list
internally.

This is needed because on unthreaded builds, asyncs inherits parent's
atexit() list, that gets run as soon as the async exit()s (and again at
the end of async's parent process). That led to remove temporary files
too early.

Also remove a by-atexit-callback guard against this kind of issue in
clone.c, as this patch makes it redundant.

Fixes test 5537 (temporary shallow file vanished before unpack-objects
could open it)

BTW remove an unused variable in shallow.c.

Helped-by: Duy Nguyen &lt;pclouds@gmail.com&gt;
Helped-by: Andreas Schwab &lt;schwab@linux-m68k.org&gt;
Helped-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Etienne Buira &lt;etienne.buira@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>run-command: add env_array, an optional argv_array for env</title>
<updated>2014-10-19T22:26:31Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2014-10-19T11:13:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=19a583dc39e3e1110f746e837c5ce1953d6ebfa1'/>
<id>urn:sha1:19a583dc39e3e1110f746e837c5ce1953d6ebfa1</id>
<content type='text'>
Similar to args, add a struct argv_array member to struct child_process
that simplifies specifying the environment for children.  It is freed
automatically by finish_command() or if start_command() encounters an
error.

Suggested-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
