]> git.ipfire.org Git - thirdparty/git.git/blame - sub-process.h
Merge branch 'ls/filter-process-delayed' into jt/subprocess-handshake
[thirdparty/git.git] / sub-process.h
CommitLineData
99605d62
BP
1#ifndef SUBPROCESS_H
2#define SUBPROCESS_H
3
4#include "git-compat-util.h"
5#include "hashmap.h"
6#include "run-command.h"
7
8/*
9 * Generic implementation of background process infrastructure.
97e2ff46 10 * See: Documentation/technical/api-sub-process.txt
99605d62
BP
11 */
12
13 /* data structures */
14
15struct subprocess_entry {
16 struct hashmap_entry ent; /* must be the first member! */
17 const char *cmd;
18 struct child_process process;
19};
20
21/* subprocess functions */
22
7663cdc8
SB
23extern int cmd2process_cmp(const void *unused_cmp_data,
24 const struct subprocess_entry *e1,
25 const struct subprocess_entry *e2,
26 const void *unused_keydata);
99605d62
BP
27
28typedef int(*subprocess_start_fn)(struct subprocess_entry *entry);
29int subprocess_start(struct hashmap *hashmap, struct subprocess_entry *entry, const char *cmd,
30 subprocess_start_fn startfn);
31
32void subprocess_stop(struct hashmap *hashmap, struct subprocess_entry *entry);
33
34struct subprocess_entry *subprocess_find_entry(struct hashmap *hashmap, const char *cmd);
35
36/* subprocess helper functions */
37
38static inline struct child_process *subprocess_get_child_process(
39 struct subprocess_entry *entry)
40{
41 return &entry->process;
42}
43
44/*
45 * Helper function that will read packets looking for "status=<foo>"
46 * key/value pairs and return the value from the last "status" packet
47 */
48
4f2a2e9f 49int subprocess_read_status(int fd, struct strbuf *status);
99605d62
BP
50
51#endif