1#ifndef SUBPROCESS_H
2#define SUBPROCESS_H
34
#include "git-compat-util.h"
5#include "hashmap.h"
6#include "run-command.h"
78
/*
9* Generic implementation of background process infrastructure.
10* See: Documentation/technical/api-sub-process.txt
11*/
1213
/* data structures */
1415
struct subprocess_entry {
16struct hashmap_entry ent; /* must be the first member! */
17const char *cmd;
18struct child_process process;
19};
2021
/* subprocess functions */
2223
int cmd2process_cmp(const struct subprocess_entry *e1,
24const struct subprocess_entry *e2, const void *unused);
2526
typedef int(*subprocess_start_fn)(struct subprocess_entry *entry);
27int subprocess_start(struct hashmap *hashmap, struct subprocess_entry *entry, const char *cmd,
28subprocess_start_fn startfn);
2930
void subprocess_stop(struct hashmap *hashmap, struct subprocess_entry *entry);
3132
struct subprocess_entry *subprocess_find_entry(struct hashmap *hashmap, const char *cmd);
3334
/* subprocess helper functions */
3536
static inline struct child_process *subprocess_get_child_process(
37struct subprocess_entry *entry)
38{
39return &entry->process;
40}
4142
/*
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*/
4647
int subprocess_read_status(int fd, struct strbuf *status);
4849
#endif