mirror of
https://github.com/neovim/neovim.git
synced 2026-01-20 04:01:15 +10:00
1. Don't check elapsed time in children_kill_cb(), it's already implied by the start-time of the timer itself. 2. Restart timer from children_kill_cb() for PTY jobs, to send SIGKILL after SIGTERM. There is an edge case where SIGKILL might follow SIGTERM too quickly, if jobstop() is called near the 2-second timer window. But this edge case is not worth code complication.
66 lines
1.4 KiB
C
66 lines
1.4 KiB
C
#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;
|
|
uint64_t stopped_time; // process_stop() timestamp
|
|
const char *cwd;
|
|
char **argv;
|
|
Stream in, out, err;
|
|
process_exit_cb cb;
|
|
internal_process_cb internal_exit_cb, internal_close_cb;
|
|
bool closed, detach;
|
|
MultiQueue *events;
|
|
};
|
|
|
|
|
|
static inline Process process_init(Loop *loop, ProcessType type, void *data)
|
|
{
|
|
return (Process) {
|
|
.type = type,
|
|
.data = data,
|
|
.loop = loop,
|
|
.events = NULL,
|
|
.pid = 0,
|
|
.status = -1,
|
|
.refcount = 0,
|
|
.stopped_time = 0,
|
|
.cwd = NULL,
|
|
.argv = NULL,
|
|
.in = { .closed = false },
|
|
.out = { .closed = false },
|
|
.err = { .closed = false },
|
|
.cb = NULL,
|
|
.closed = false,
|
|
.internal_close_cb = NULL,
|
|
.internal_exit_cb = NULL,
|
|
.detach = false
|
|
};
|
|
}
|
|
|
|
static inline bool process_is_stopped(Process *proc)
|
|
{
|
|
return proc->stopped_time != 0;
|
|
}
|
|
|
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
|
# include "event/process.h.generated.h"
|
|
#endif
|
|
#endif // NVIM_EVENT_PROCESS_H
|