process.h
Go to the documentation of this file.
1 #ifndef NVIM_EVENT_PROCESS_H
2 #define NVIM_EVENT_PROCESS_H
3 
4 #include "nvim/event/loop.h"
5 #include "nvim/event/rstream.h"
6 #include "nvim/event/wstream.h"
7 
8 typedef enum {
11 } ProcessType;
12 
13 typedef struct process Process;
14 typedef void (*process_exit_cb)(Process *proc, int status, void *data);
15 typedef void (*internal_process_cb)(Process *proc);
16 
17 struct process {
20  void *data;
22  uint64_t stopped_time; // process_stop() timestamp
23  const char *cwd;
24  char **argv;
28  bool closed, detach;
30 };
31 
32 
33 static inline Process process_init(Loop *loop, ProcessType type, void *data)
34 {
35  return (Process) {
36  .type = type,
37  .data = data,
38  .loop = loop,
39  .events = NULL,
40  .pid = 0,
41  .status = -1,
42  .refcount = 0,
43  .stopped_time = 0,
44  .cwd = NULL,
45  .argv = NULL,
46  .in = { .closed = false },
47  .out = { .closed = false },
48  .err = { .closed = false },
49  .cb = NULL,
50  .closed = false,
51  .internal_close_cb = NULL,
52  .internal_exit_cb = NULL,
53  .detach = false
54  };
55 }
56 
57 static inline bool process_is_stopped(Process *proc)
58 {
59  return proc->stopped_time != 0;
60 }
61 
62 #ifdef INCLUDE_GENERATED_DECLARATIONS
63 # include "event/process.h.generated.h"
64 #endif
65 #endif // NVIM_EVENT_PROCESS_H
Definition: process.h:17
process_exit_cb cb
Definition: process.h:26
bool closed
Definition: process.h:28
ProcessType
Definition: process.h:8
Stream in
Definition: process.h:25
internal_process_cb internal_exit_cb
Definition: process.h:27
internal_process_cb internal_close_cb
Definition: process.h:27
return NULL
Definition: eval.c:22200
void * data
Definition: process.h:20
Definition: process.h:10
char ** argv
Definition: process.h:24
void(* internal_process_cb)(Process *proc)
Definition: process.h:15
void(* process_exit_cb)(Process *proc, int status, void *data)
Definition: process.h:14
const char * cwd
Definition: process.h:23
int status
Definition: process.h:21
uint64_t stopped_time
Definition: process.h:22
bool detach
Definition: process.h:28
Stream err
Definition: process.h:25
Stream out
Definition: process.h:25
Definition: stream.h:32
Definition: loop.h:17
Definition: process.h:9
Loop * loop
Definition: process.h:19
int refcount
Definition: process.h:21
MultiQueue * events
Definition: process.h:29
Definition: multiqueue.c:73
MultiQueue * events
Definition: loop.h:19
ProcessType type
Definition: process.h:18
int pid
Definition: process.h:21