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  uint8_t exit_signal; // Signal used when killing (on Windows).
23  uint64_t stopped_time; // process_stop() timestamp
24  const char *cwd;
25  char **argv;
26  char **env;
30  bool closed, detach;
32 };
33 
34 
35 static inline Process process_init(Loop *loop, ProcessType type, void *data)
36 {
37  return (Process) {
38  .type = type,
39  .data = data,
40  .loop = loop,
41  .events = NULL,
42  .pid = 0,
43  .status = -1,
44  .refcount = 0,
45  .stopped_time = 0,
46  .cwd = NULL,
47  .argv = NULL,
48  .in = { .closed = false },
49  .out = { .closed = false },
50  .err = { .closed = false },
51  .cb = NULL,
52  .closed = false,
53  .internal_close_cb = NULL,
54  .internal_exit_cb = NULL,
55  .detach = false
56  };
57 }
58 
59 static inline bool process_is_stopped(Process *proc)
60 {
61  bool exited = (proc->status >= 0);
62  return exited || (proc->stopped_time != 0);
63 }
64 
65 #ifdef INCLUDE_GENERATED_DECLARATIONS
66 # include "event/process.h.generated.h"
67 #endif
68 #endif // NVIM_EVENT_PROCESS_H
Definition: process.h:17
process_exit_cb cb
Definition: process.h:28
bool closed
Definition: process.h:30
ProcessType
Definition: process.h:8
Stream in
Definition: process.h:27
Definition: query.c:15
internal_process_cb internal_exit_cb
Definition: process.h:29
internal_process_cb internal_close_cb
Definition: process.h:29
uint8_t exit_signal
Definition: process.h:22
return NULL
Definition: eval.c:13033
void * data
Definition: process.h:20
Definition: process.h:10
char ** argv
Definition: process.h:25
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:24
int status
Definition: process.h:21
uint64_t stopped_time
Definition: process.h:23
bool detach
Definition: process.h:30
Stream err
Definition: process.h:27
Stream out
Definition: process.h:27
void(WINAPI *pClosePseudoConsole)(HPCON)
Definition: loop.h:17
char ** env
Definition: process.h:26
Definition: process.h:9
Loop * loop
Definition: process.h:19
int refcount
Definition: process.h:21
MultiQueue * events
Definition: process.h:31
Definition: multiqueue.c:73
MultiQueue * events
Definition: loop.h:19
ProcessType type
Definition: process.h:18
int pid
Definition: process.h:21