summaryrefslogtreecommitdiff
path: root/sub-process.h
diff options
context:
space:
mode:
authorBen Peart <peartben@gmail.com>2017-05-05 15:28:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-05-15 04:01:57 (GMT)
commit99605d62e8e7e568035dc953b24b79b3d52f0522 (patch)
tree4a55a99f460e16e0b2bbcce036f3611534357f5c /sub-process.h
parentf514d7d177f7cabbacc3f2cda96ca211266ac2ff (diff)
downloadgit-99605d62e8e7e568035dc953b24b79b3d52f0522.zip
git-99605d62e8e7e568035dc953b24b79b3d52f0522.tar.gz
git-99605d62e8e7e568035dc953b24b79b3d52f0522.tar.bz2
sub-process: move sub-process functions into separate files
Move the sub-proces functions into sub-process.h/c. Add documentation for the new module in Documentation/technical/api-sub-process.txt Signed-off-by: Ben Peart <benpeart@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sub-process.h')
-rw-r--r--sub-process.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/sub-process.h b/sub-process.h
new file mode 100644
index 0000000..a88e782
--- /dev/null
+++ b/sub-process.h
@@ -0,0 +1,49 @@
+#ifndef SUBPROCESS_H
+#define SUBPROCESS_H
+
+#include "git-compat-util.h"
+#include "hashmap.h"
+#include "run-command.h"
+
+/*
+ * Generic implementation of background process infrastructure.
+ * See Documentation/technical/api-background-process.txt.
+ */
+
+ /* data structures */
+
+struct subprocess_entry {
+ struct hashmap_entry ent; /* must be the first member! */
+ const char *cmd;
+ struct child_process process;
+};
+
+/* subprocess functions */
+
+int cmd2process_cmp(const struct subprocess_entry *e1,
+ const struct subprocess_entry *e2, const void *unused);
+
+typedef int(*subprocess_start_fn)(struct subprocess_entry *entry);
+int subprocess_start(struct hashmap *hashmap, struct subprocess_entry *entry, const char *cmd,
+ subprocess_start_fn startfn);
+
+void subprocess_stop(struct hashmap *hashmap, struct subprocess_entry *entry);
+
+struct subprocess_entry *subprocess_find_entry(struct hashmap *hashmap, const char *cmd);
+
+/* subprocess helper functions */
+
+static inline struct child_process *subprocess_get_child_process(
+ struct subprocess_entry *entry)
+{
+ return &entry->process;
+}
+
+/*
+ * Helper function that will read packets looking for "status=<foo>"
+ * key/value pairs and return the value from the last "status" packet
+ */
+
+void subprocess_read_status(int fd, struct strbuf *status);
+
+#endif