environment: remove namespace_len variable
[git/debian.git] / sub-process.h
blobd9a45cd359a780d77d2dc01bd8a315d49a6a994f
1 #ifndef SUBPROCESS_H
2 #define SUBPROCESS_H
4 #include "git-compat-util.h"
5 #include "hashmap.h"
6 #include "run-command.h"
8 /*
9 * Generic implementation of background process infrastructure.
10 * See: Documentation/technical/api-sub-process.txt
13 /* data structures */
15 struct subprocess_entry {
16 struct hashmap_entry ent; /* must be the first member! */
17 const char *cmd;
18 struct child_process process;
21 /* subprocess functions */
23 int cmd2process_cmp(const struct subprocess_entry *e1,
24 const struct subprocess_entry *e2, const void *unused);
26 typedef int(*subprocess_start_fn)(struct subprocess_entry *entry);
27 int subprocess_start(struct hashmap *hashmap, struct subprocess_entry *entry, const char *cmd,
28 subprocess_start_fn startfn);
30 void subprocess_stop(struct hashmap *hashmap, struct subprocess_entry *entry);
32 struct subprocess_entry *subprocess_find_entry(struct hashmap *hashmap, const char *cmd);
34 /* subprocess helper functions */
36 static inline struct child_process *subprocess_get_child_process(
37 struct subprocess_entry *entry)
39 return &entry->process;
43 * Helper function that will read packets looking for "status=<foo>"
44 * key/value pairs and return the value from the last "status" packet
47 int subprocess_read_status(int fd, struct strbuf *status);
49 #endif