1#ifndef SUBPROCESS_H2#define SUBPROCESS_H34#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.txt11*/1213/* data structures */1415struct subprocess_entry {16struct hashmap_entry ent; /* must be the first member! */17const char *cmd;18struct child_process process;19};2021/* subprocess functions */2223extern int cmd2process_cmp(const void *unused_cmp_data,24const struct subprocess_entry *e1,25const struct subprocess_entry *e2,26const void *unused_keydata);2728typedef int(*subprocess_start_fn)(struct subprocess_entry *entry);29int subprocess_start(struct hashmap *hashmap, struct subprocess_entry *entry, const char *cmd,30subprocess_start_fn startfn);3132void subprocess_stop(struct hashmap *hashmap, struct subprocess_entry *entry);3334struct subprocess_entry *subprocess_find_entry(struct hashmap *hashmap, const char *cmd);3536/* subprocess helper functions */3738static inline struct child_process *subprocess_get_child_process(39struct subprocess_entry *entry)40{41return &entry->process;42}4344/*45* Helper function that will read packets looking for "status=<foo>"46* key/value pairs and return the value from the last "status" packet47*/4849int subprocess_read_status(int fd, struct strbuf *status);5051#endif