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/eval/typval.h"
5 #include "nvim/event/loop.h"
6 #include "nvim/event/rstream.h"
7 #include "nvim/event/wstream.h"
8 
9 typedef enum {
12 } ProcessType;
13 
14 typedef struct process Process;
15 typedef void (*process_exit_cb)(Process *proc, int status, void *data);
16 typedef void (*internal_process_cb)(Process *proc);
17 
18 struct process {
21  void *data;
23  uint8_t exit_signal; // Signal used when killing (on Windows).
24  uint64_t stopped_time; // process_stop() timestamp
25  const char *cwd;
26  char **argv;
34 };
35 
36 
37 static inline Process process_init(Loop *loop, ProcessType type, void *data)
38 {
39  return (Process) {
40  .type = type,
41  .data = data,
42  .loop = loop,
43  .events = NULL,
44  .pid = 0,
45  .status = -1,
46  .refcount = 0,
47  .stopped_time = 0,
48  .cwd = NULL,
49  .argv = NULL,
50  .in = { .closed = false },
51  .out = { .closed = false },
52  .err = { .closed = false },
53  .cb = NULL,
54  .closed = false,
55  .internal_close_cb = NULL,
56  .internal_exit_cb = NULL,
57  .detach = false
58  };
59 }
60 
61 static inline bool process_is_stopped(Process *proc)
62 {
63  bool exited = (proc->status >= 0);
64  return exited || (proc->stopped_time != 0);
65 }
66 
67 #ifdef INCLUDE_GENERATED_DECLARATIONS
68 # include "event/process.h.generated.h"
69 #endif
70 #endif // NVIM_EVENT_PROCESS_H
process::pid
int pid
Definition: process.h:22
process::loop
Loop * loop
Definition: process.h:20
process::in
Stream in
Definition: process.h:28
process::internal_close_cb
internal_process_cb internal_close_cb
Definition: process.h:31
process::refcount
int refcount
Definition: process.h:22
process::cb
process_exit_cb cb
Exit handler. If set, user must call process_free().
Definition: process.h:30
process::internal_exit_cb
internal_process_cb internal_exit_cb
Definition: process.h:31
process::env
dict_T * env
Definition: process.h:27
type
err type
Definition: helpers.c:1114
process::cwd
const char * cwd
Definition: process.h:25
ProcessType
ProcessType
Definition: process.h:9
process::stopped_time
uint64_t stopped_time
Definition: process.h:24
process::exit_signal
uint8_t exit_signal
Definition: process.h:23
process::argv
char ** argv
Definition: process.h:26
process::status
int status
Definition: process.h:22
void
void(WINAPI *pClosePseudoConsole)(HPCON)
stream
Definition: stream.h:31
process::data
void * data
Definition: process.h:21
process::detach
bool detach
Definition: process.h:32
process::err
Stream err
Definition: process.h:28
process::overlapped
bool overlapped
Definition: process.h:32
process::out
Stream out
Definition: process.h:28
kProcessTypeUv
@ kProcessTypeUv
Definition: process.h:10
process_exit_cb
void(* process_exit_cb)(Process *proc, int status, void *data)
Definition: process.h:15
typval.h
multiqueue
Definition: multiqueue.c:71
process
Definition: process.h:18
internal_process_cb
void(* internal_process_cb)(Process *proc)
Definition: process.h:16
loop.h
rstream.h
process::events
MultiQueue * events
Definition: process.h:33
kProcessTypePty
@ kProcessTypePty
Definition: process.h:11
wstream.h
dict_T
Definition: coverity-model.c:40
loop::events
MultiQueue * events
Definition: loop.h:18
process::closed
bool closed
Definition: process.h:32
NULL
return NULL
Definition: eval.c:9968
process::type
ProcessType type
Definition: process.h:19
loop
Definition: loop.h:16