aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/event/process.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/event/process.h')
-rw-r--r--src/nvim/event/process.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/nvim/event/process.h b/src/nvim/event/process.h
new file mode 100644
index 0000000000..5c84a7d1d0
--- /dev/null
+++ b/src/nvim/event/process.h
@@ -0,0 +1,56 @@
+#ifndef NVIM_EVENT_PROCESS_H
+#define NVIM_EVENT_PROCESS_H
+
+#include "nvim/event/loop.h"
+#include "nvim/event/rstream.h"
+#include "nvim/event/wstream.h"
+
+typedef enum {
+ kProcessTypeUv,
+ kProcessTypePty
+} ProcessType;
+
+typedef struct process Process;
+typedef void (*process_exit_cb)(Process *proc, int status, void *data);
+typedef void (*internal_process_cb)(Process *proc);
+
+struct process {
+ ProcessType type;
+ Loop *loop;
+ void *data;
+ int pid, status, refcount;
+ // set to the hrtime of when process_stop was called for the process.
+ uint64_t stopped_time;
+ char **argv;
+ Stream *in, *out, *err;
+ process_exit_cb cb;
+ internal_process_cb internal_exit_cb, internal_close_cb;
+ bool closed, term_sent;
+};
+
+static inline Process process_init(ProcessType type, void *data)
+{
+ return (Process) {
+ .type = type,
+ .data = data,
+ .loop = NULL,
+ .pid = 0,
+ .status = 0,
+ .refcount = 0,
+ .stopped_time = 0,
+ .argv = NULL,
+ .in = NULL,
+ .out = NULL,
+ .err = NULL,
+ .cb = NULL,
+ .closed = false,
+ .term_sent = false,
+ .internal_close_cb = NULL,
+ .internal_exit_cb = NULL
+ };
+}
+
+#ifdef INCLUDE_GENERATED_DECLARATIONS
+# include "event/process.h.generated.h"
+#endif
+#endif // NVIM_EVENT_PROCESS_H