]> git.ipfire.org Git - thirdparty/git.git/blame - sub-process.h
sub-process: move sub-process functions into separate files
[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.
10 * See Documentation/technical/api-background-process.txt.
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
23int cmd2process_cmp(const struct subprocess_entry *e1,
24 const struct subprocess_entry *e2, const void *unused);
25
26typedef int(*subprocess_start_fn)(struct subprocess_entry *entry);
27int subprocess_start(struct hashmap *hashmap, struct subprocess_entry *entry, const char *cmd,
28 subprocess_start_fn startfn);
29
30void subprocess_stop(struct hashmap *hashmap, struct subprocess_entry *entry);
31
32struct subprocess_entry *subprocess_find_entry(struct hashmap *hashmap, const char *cmd);
33
34/* subprocess helper functions */
35
36static inline struct child_process *subprocess_get_child_process(
37 struct subprocess_entry *entry)
38{
39 return &entry->process;
40}
41
42/*
43 * Helper function that will read packets looking for "status=<foo>"
44 * key/value pairs and return the value from the last "status" packet
45 */
46
47void subprocess_read_status(int fd, struct strbuf *status);
48
49#endif