aboutsummaryrefslogtreecommitdiff
path: root/Documentation/technical/api-sub-process.txt
blob: 793508cf3e75d0e5c0e3ce29053ff0f4ee037b02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
sub-process API
===============

The sub-process API makes it possible to run background sub-processes
for the entire lifetime of a Git invocation. If Git needs to communicate
with an external process multiple times, then this can reduces the process
invocation overhead. Git and the sub-process communicate through stdin and
stdout.

The sub-processes are kept in a hashmap by command name and looked up
via the subprocess_find_entry function.  If an existing instance can not
be found then a new process should be created and started.  When the
parent git command terminates, all sub-processes are also terminated.

This API is based on the run-command API.

Data structures
---------------

* `struct subprocess_entry`

The sub-process structure.  Members should not be accessed directly.

Types
-----

'int(*subprocess_start_fn)(struct subprocess_entry *entry)'::

	User-supplied function to initialize the sub-process.  This is
	typically used to negotiate the interface version and capabilities.


Functions
---------

`cmd2process_cmp`::

	Function to test two subprocess hashmap entries for equality.

`subprocess_start`::

	Start a subprocess and add it to the subprocess hashmap.

`subprocess_stop`::

	Kill a subprocess and remove it from the subprocess hashmap.

`subprocess_find_entry`::

	Find a subprocess in the subprocess hashmap.

`subprocess_get_child_process`::

	Get the underlying `struct child_process` from a subprocess.

`subprocess_read_status`::

	Helper function to read packets looking for the last "status=<foo>"
	key/value pair.