<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/Documentation/technical/api-run-command.txt, branch v2.22.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.22.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.22.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2015-11-02T23:01:00Z</updated>
<entry>
<title>run-command: factor out child_process_clear()</title>
<updated>2015-11-02T23:01:00Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2015-10-24T12:11:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2d71608ec0b6d098ed7c8c914fb7004b28349995'/>
<id>urn:sha1:2d71608ec0b6d098ed7c8c914fb7004b28349995</id>
<content type='text'>
Avoid duplication by moving the code to release allocated memory for
arguments and environment to its own function, child_process_clear().
Export it to provide a counterpart to child_process_init().

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 'rs/child-process-init'</title>
<updated>2014-10-31T18:49:49Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-10-31T18:49:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=598d7eb160c46e55cf5dc07d04c8c917bc0dd646'/>
<id>urn:sha1:598d7eb160c46e55cf5dc07d04c8c917bc0dd646</id>
<content type='text'>
* rs/child-process-init:
  api-run-command: add missing list item marker
</content>
</entry>
<entry>
<title>api-run-command: add missing list item marker</title>
<updated>2014-10-28T22:25:25Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2014-10-28T22:09:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=96ef1bdc654932cf2707a1b70a9502842a1014f7'/>
<id>urn:sha1:96ef1bdc654932cf2707a1b70a9502842a1014f7</id>
<content type='text'>
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>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>
<entry>
<title>run-command: introduce child_process_init()</title>
<updated>2014-08-20T16:54:58Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2014-08-19T19:10:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=483bbd4e4ce8a5c717cd47d732893317a14c965a'/>
<id>urn:sha1:483bbd4e4ce8a5c717cd47d732893317a14c965a</id>
<content type='text'>
Add a helper function for initializing those struct child_process
variables for which the macro CHILD_PROCESS_INIT can't be used.

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>
<entry>
<title>run-command: introduce CHILD_PROCESS_INIT</title>
<updated>2014-08-20T16:53:37Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2014-08-19T19:09:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d3180279322c7450a47decf8833de47f444ca93f'/>
<id>urn:sha1:d3180279322c7450a47decf8833de47f444ca93f</id>
<content type='text'>
Most struct child_process variables are cleared using memset first after
declaration.  Provide a macro, CHILD_PROCESS_INIT, that can be used to
initialize them statically instead.  That's shorter, doesn't require a
function call and is slightly more readable (especially given that we
already have STRBUF_INIT, ARGV_ARRAY_INIT etc.).

Helped-by: Johannes Sixt &lt;j6t@kdbg.org&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>
<entry>
<title>run-command: store an optional argv_array</title>
<updated>2014-05-15T16:49:09Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-05-15T08:33:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c460c0ecdca46be85f6d9c845f9df7ce0e45c3c2'/>
<id>urn:sha1:c460c0ecdca46be85f6d9c845f9df7ce0e45c3c2</id>
<content type='text'>
All child_process structs need to point to an argv. For
flexibility, we do not mandate the use of a dynamic
argv_array. However, because the child_process does not own
the memory, this can make memory management with a
separate argv_array difficult.

For example, if a function calls start_command but not
finish_command, the argv memory must persist. The code needs
to arrange to clean up the argv_array separately after
finish_command runs. As a result, some of our code in this
situation just leaks the memory.

To help such cases, this patch adds a built-in argv_array to
the child_process, which gets cleaned up automatically (both
in finish_command and when start_command fails).  Callers
may use it if they choose, but can continue to use the raw
argv if they wish.

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: encode signal death as a positive integer</title>
<updated>2013-01-06T19:09:18Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2013-01-05T14:49:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=709ca730f8e093005cc882bfb86c0ca9c83d345b'/>
<id>urn:sha1:709ca730f8e093005cc882bfb86c0ca9c83d345b</id>
<content type='text'>
When a sub-command dies due to a signal, we encode the
signal number into the numeric exit status as "signal -
128". This is easy to identify (versus a regular positive
error code), and when cast to an unsigned integer (e.g., by
feeding it to exit), matches what a POSIX shell would return
when reporting a signal death in $? or through its own exit
code.

So we have a negative value inside the code, but once it
passes across an exit() barrier, it looks positive (and any
code we receive from a sub-shell will have the positive
form). E.g., death by SIGPIPE (signal 13) will look like
-115 to us in inside git, but will end up as 141 when we
call exit() with it. And a program killed by SIGPIPE but run
via the shell will come to us with an exit code of 141.

Unfortunately, this means that when the "use_shell" option
is set, we need to be on the lookout for _both_ forms. We
might or might not have actually invoked the shell (because
we optimize out some useless shell calls). If we didn't invoke
the shell, we will will see the sub-process's signal death
directly, and run-command converts it into a negative value.
But if we did invoke the shell, we will see the shell's
128+signal exit status. To be thorough, we would need to
check both, or cast the value to an unsigned char (after
checking that it is not -1, which is a magic error value).

Fortunately, most callsites do not care at all whether the
exit was from a code or from a signal; they merely check for
a non-zero status, and sometimes propagate the error via
exit(). But for the callers that do care, we can make life
slightly easier by just using the consistent positive form.

This actually fixes two minor bugs:

  1. In launch_editor, we check whether the editor died from
     SIGINT or SIGQUIT. But we checked only the negative
     form, meaning that we would fail to notice a signal
     death exit code which was propagated through the shell.

  2. In handle_alias, we assume that a negative return value
     from run_command means that errno tells us something
     interesting (like a fork failure, or ENOENT).
     Otherwise, we simply propagate the exit code. Negative
     signal death codes confuse us, and we print a useless
     "unable to run alias 'foo': Success" message. By
     encoding signal deaths using the positive form, the
     existing code just propagates it as it would a normal
     non-zero exit code.

The downside is that callers of run_command can no longer
differentiate between a signal received directly by the
sub-process, and one propagated. However, no caller
currently cares, and since we already optimize out some
calls to the shell under the hood, that distinction is not
something that should be relied upon by callers.

Fix the same logic in t/test-terminal.perl for consistency [jc:
raised by Jonathan in the discussion].

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Acked-by: Johannes Sixt &lt;j6t@kdbg.org&gt;
Reviewed-by: Jonathan Nieder &lt;jrnieder@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Enable threaded async procedures whenever pthreads is available</title>
<updated>2010-03-10T22:26:54Z</updated>
<author>
<name>Johannes Sixt</name>
<email>j6t@kdbg.org</email>
</author>
<published>2010-03-09T20:00:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f6b6098316192475ff0b3fa2ba894d7e555bdfac'/>
<id>urn:sha1:f6b6098316192475ff0b3fa2ba894d7e555bdfac</id>
<content type='text'>
Signed-off-by: Johannes Sixt &lt;j6t@kdbg.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'sp/push-sideband'</title>
<updated>2010-02-21T20:00:07Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2010-02-21T20:00:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5f8a0de98b727b9bfaea0f3318066109fd6745b8'/>
<id>urn:sha1:5f8a0de98b727b9bfaea0f3318066109fd6745b8</id>
<content type='text'>
* sp/push-sideband:
  receive-pack: Send internal errors over side-band #2
  t5401: Use a bare repository for the remote peer
  receive-pack: Send hook output over side band #2
  receive-pack: Wrap status reports inside side-band-64k
  receive-pack: Refactor how capabilities are shown to the client
  send-pack: demultiplex a sideband stream with status data
  run-command: support custom fd-set in async
  run-command: Allow stderr to be a caller supplied pipe
</content>
</entry>
</feed>
