diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2024-09-15 12:20:58 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-15 12:20:58 -0700 |
| commit | 057d27a9d6ef0bb2ee5130704c45b9e9197e7c36 (patch) | |
| tree | c08b0d80b543cc18dd1dec97dde9885b8a50b375 /src/nvim | |
| parent | 5792546777332361a9ac49107e46149c703de90e (diff) | |
| download | rneovim-057d27a9d6ef0bb2ee5130704c45b9e9197e7c36.tar.gz rneovim-057d27a9d6ef0bb2ee5130704c45b9e9197e7c36.tar.bz2 rneovim-057d27a9d6ef0bb2ee5130704c45b9e9197e7c36.zip | |
refactor: rename "process" => "proc" #30387
Problem:
- "process" is often used as a verb (`multiqueue_process_events`), which
is ambiguous for cases where it's used as a topic.
- The documented naming convention for processes is "proc".
- `:help dev-name-common`
- Shorter is better, when it doesn't harm readability or
discoverability.
Solution:
Rename "process" => "proc" in all C symbols and module names.
Diffstat (limited to 'src/nvim')
| -rw-r--r-- | src/nvim/CMakeLists.txt | 10 | ||||
| -rw-r--r-- | src/nvim/api/vim.c | 2 | ||||
| -rw-r--r-- | src/nvim/channel.c | 36 | ||||
| -rw-r--r-- | src/nvim/channel.h | 10 | ||||
| -rw-r--r-- | src/nvim/eval.c | 4 | ||||
| -rw-r--r-- | src/nvim/eval/funcs.c | 24 | ||||
| -rw-r--r-- | src/nvim/event/defs.h | 25 | ||||
| -rw-r--r-- | src/nvim/event/libuv_proc.c (renamed from src/nvim/event/libuv_process.c) | 26 | ||||
| -rw-r--r-- | src/nvim/event/libuv_proc.h (renamed from src/nvim/event/libuv_process.h) | 6 | ||||
| -rw-r--r-- | src/nvim/event/proc.c (renamed from src/nvim/event/process.c) | 126 | ||||
| -rw-r--r-- | src/nvim/event/proc.h (renamed from src/nvim/event/process.h) | 10 | ||||
| -rw-r--r-- | src/nvim/main.c | 6 | ||||
| -rw-r--r-- | src/nvim/memline.c | 22 | ||||
| -rw-r--r-- | src/nvim/msgpack_rpc/channel.c | 2 | ||||
| -rw-r--r-- | src/nvim/os/env.c | 2 | ||||
| -rw-r--r-- | src/nvim/os/proc.c (renamed from src/nvim/os/process.c) | 12 | ||||
| -rw-r--r-- | src/nvim/os/proc.h (renamed from src/nvim/os/process.h) | 2 | ||||
| -rw-r--r-- | src/nvim/os/pty_conpty_win.c | 4 | ||||
| -rw-r--r-- | src/nvim/os/pty_proc.h | 7 | ||||
| -rw-r--r-- | src/nvim/os/pty_proc_unix.c (renamed from src/nvim/os/pty_process_unix.c) | 40 | ||||
| -rw-r--r-- | src/nvim/os/pty_proc_unix.h (renamed from src/nvim/os/pty_process_unix.h) | 8 | ||||
| -rw-r--r-- | src/nvim/os/pty_proc_win.c (renamed from src/nvim/os/pty_process_win.c) | 86 | ||||
| -rw-r--r-- | src/nvim/os/pty_proc_win.h (renamed from src/nvim/os/pty_process_win.h) | 12 | ||||
| -rw-r--r-- | src/nvim/os/pty_process.h | 7 | ||||
| -rw-r--r-- | src/nvim/os/shell.c | 14 | ||||
| -rw-r--r-- | src/nvim/profile.c | 6 |
26 files changed, 255 insertions, 254 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index ab08f01e33..3cc1a2c8f0 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -417,10 +417,10 @@ list(SORT NVIM_HEADERS) foreach(sfile ${NVIM_SOURCES}) get_filename_component(f ${sfile} NAME) - if(WIN32 AND ${f} MATCHES "^(pty_process_unix.c)$") + if(WIN32 AND ${f} MATCHES "^(pty_proc_unix.c)$") list(REMOVE_ITEM NVIM_SOURCES ${sfile}) endif() - if(NOT WIN32 AND ${f} MATCHES "^(pty_process_win.c)$") + if(NOT WIN32 AND ${f} MATCHES "^(pty_proc_win.c)$") list(REMOVE_ITEM NVIM_SOURCES ${sfile}) endif() if(NOT WIN32 AND ${f} MATCHES "^(pty_conpty_win.c)$") @@ -436,7 +436,7 @@ foreach(hfile ${NVIM_HEADERS}) if(WIN32 AND ${f} MATCHES "^(unix_defs.h)$") list(REMOVE_ITEM NVIM_HEADERS ${hfile}) endif() - if(WIN32 AND ${f} MATCHES "^(pty_process_unix.h)$") + if(WIN32 AND ${f} MATCHES "^(pty_proc_unix.h)$") list(REMOVE_ITEM NVIM_HEADERS ${hfile}) endif() if(NOT WIN32 AND ${f} MATCHES "^(win_defs.h)$") @@ -832,12 +832,12 @@ find_program(CLANG_TIDY_PRG clang-tidy) set(EXCLUDE_CLANG_TIDY typval_encode.c.h ui_events.in.h) if(WIN32) list(APPEND EXCLUDE_CLANG_TIDY - os/pty_process_unix.h + os/pty_proc_unix.h os/unix_defs.h) else() list(APPEND EXCLUDE_CLANG_TIDY os/win_defs.h - os/pty_process_win.h + os/pty_proc_win.h os/pty_conpty_win.h os/os_win_console.h) endif() diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 630c534a7f..fe263d051d 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -70,7 +70,7 @@ #include "nvim/optionstr.h" #include "nvim/os/input.h" #include "nvim/os/os_defs.h" -#include "nvim/os/process.h" +#include "nvim/os/proc.h" #include "nvim/popupmenu.h" #include "nvim/pos_defs.h" #include "nvim/runtime.h" diff --git a/src/nvim/channel.c b/src/nvim/channel.c index 5f9bfc3a73..d60c03e1ba 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -19,7 +19,7 @@ #include "nvim/eval/typval.h" #include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" -#include "nvim/event/process.h" +#include "nvim/event/proc.h" #include "nvim/event/rstream.h" #include "nvim/event/socket.h" #include "nvim/event/stream.h" @@ -88,7 +88,7 @@ void channel_free_all_mem(void) bool channel_close(uint64_t id, ChannelPart part, const char **error) { Channel *chan; - Process *proc; + Proc *proc; const char *dummy; if (!error) { @@ -139,8 +139,8 @@ bool channel_close(uint64_t id, ChannelPart part, const char **error) if (part == kChannelPartStderr || part == kChannelPartAll) { rstream_may_close(&proc->err); } - if (proc->type == kProcessTypePty && part == kChannelPartAll) { - pty_process_close_master(&chan->stream.pty); + if (proc->type == kProcTypePty && part == kChannelPartAll) { + pty_proc_close_master(&chan->stream.pty); } break; @@ -289,7 +289,7 @@ static void channel_destroy(Channel *chan) } if (chan->streamtype == kChannelStreamProc) { - process_free(&chan->stream.proc); + proc_free(&chan->stream.proc); } callback_reader_free(&chan->on_data); @@ -376,7 +376,7 @@ Channel *channel_job_start(char **argv, const char *exepath, CallbackReader on_s *status_out = 0; return NULL; } - chan->stream.pty = pty_process_init(&main_loop, chan); + chan->stream.pty = pty_proc_init(&main_loop, chan); if (pty_width > 0) { chan->stream.pty.width = pty_width; } @@ -384,22 +384,22 @@ Channel *channel_job_start(char **argv, const char *exepath, CallbackReader on_s chan->stream.pty.height = pty_height; } } else { - chan->stream.uv = libuv_process_init(&main_loop, chan); + chan->stream.uv = libuv_proc_init(&main_loop, chan); } - Process *proc = &chan->stream.proc; + Proc *proc = &chan->stream.proc; proc->argv = argv; proc->exepath = exepath; - proc->cb = channel_process_exit_cb; + proc->cb = channel_proc_exit_cb; proc->events = chan->events; proc->detach = detach; proc->cwd = cwd; proc->env = env; proc->overlapped = overlapped; - char *cmd = xstrdup(process_get_exepath(proc)); + char *cmd = xstrdup(proc_get_exepath(proc)); bool has_out, has_err; - if (proc->type == kProcessTypePty) { + if (proc->type == kProcTypePty) { has_out = true; has_err = false; } else { @@ -410,7 +410,7 @@ Channel *channel_job_start(char **argv, const char *exepath, CallbackReader on_s bool has_in = stdin_mode == kChannelStdinPipe; - int status = process_spawn(proc, has_in, has_out, has_err); + int status = proc_spawn(proc, has_in, has_out, has_err); if (status) { semsg(_(e_jobspawn), os_strerror(status), cmd); xfree(cmd); @@ -760,7 +760,7 @@ void channel_reader_callbacks(Channel *chan, CallbackReader *reader) } } -static void channel_process_exit_cb(Process *proc, int status, void *data) +static void channel_proc_exit_cb(Proc *proc, int status, void *data) { Channel *chan = data; if (chan->term) { @@ -847,7 +847,7 @@ static void term_write(const char *buf, size_t size, void *data) static void term_resize(uint16_t width, uint16_t height, void *data) { Channel *chan = data; - pty_process_resize(&chan->stream.pty, width, height); + pty_proc_resize(&chan->stream.pty, width, height); } static inline void term_delayed_free(void **argv) @@ -867,7 +867,7 @@ static inline void term_delayed_free(void **argv) static void term_close(void *data) { Channel *chan = data; - process_stop(&chan->stream.proc); + proc_stop(&chan->stream.proc); multiqueue_put(chan->events, term_delayed_free, data); } @@ -907,7 +907,7 @@ bool channel_job_running(uint64_t id) Channel *chan = find_channel(id); return (chan && chan->streamtype == kChannelStreamProc - && !process_is_stopped(&chan->stream.proc)); + && !proc_is_stopped(&chan->stream.proc)); } Dictionary channel_info(uint64_t id, Arena *arena) @@ -924,8 +924,8 @@ Dictionary channel_info(uint64_t id, Arena *arena) switch (chan->streamtype) { case kChannelStreamProc: { stream_desc = "job"; - if (chan->stream.proc.type == kProcessTypePty) { - const char *name = pty_process_tty_name(&chan->stream.pty); + if (chan->stream.proc.type == kProcTypePty) { + const char *name = pty_proc_tty_name(&chan->stream.pty); PUT_C(info, "pty", CSTR_TO_ARENA_OBJ(arena, name)); } diff --git a/src/nvim/channel.h b/src/nvim/channel.h index 35f178c120..2327216826 100644 --- a/src/nvim/channel.h +++ b/src/nvim/channel.h @@ -7,11 +7,11 @@ #include "nvim/channel_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" #include "nvim/event/defs.h" -#include "nvim/event/libuv_process.h" +#include "nvim/event/libuv_proc.h" #include "nvim/macros_defs.h" #include "nvim/map_defs.h" #include "nvim/msgpack_rpc/channel_defs.h" -#include "nvim/os/pty_process.h" +#include "nvim/os/pty_proc.h" #include "nvim/types_defs.h" struct Channel { @@ -21,9 +21,9 @@ struct Channel { ChannelStreamType streamtype; union { - Process proc; - LibuvProcess uv; - PtyProcess pty; + Proc proc; + LibuvProc uv; + PtyProc pty; RStream socket; StdioPair stdio; StderrState err; diff --git a/src/nvim/eval.c b/src/nvim/eval.c index aa4f42bd68..d2a3584353 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -32,7 +32,7 @@ #include "nvim/eval/vars.h" #include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" -#include "nvim/event/process.h" +#include "nvim/event/proc.h" #include "nvim/event/time.h" #include "nvim/ex_cmds.h" #include "nvim/ex_docmd.h" @@ -8506,7 +8506,7 @@ Channel *find_job(uint64_t id, bool show_error) { Channel *data = find_channel(id); if (!data || data->streamtype != kChannelStreamProc - || process_is_stopped(&data->stream.proc)) { + || proc_is_stopped(&data->stream.proc)) { if (show_error) { if (data && data->streamtype != kChannelStreamProc) { emsg(_(e_invchanjob)); diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index aed6fdae14..ef638802ad 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -49,7 +49,7 @@ #include "nvim/event/defs.h" #include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" -#include "nvim/event/process.h" +#include "nvim/event/proc.h" #include "nvim/event/time.h" #include "nvim/ex_cmds.h" #include "nvim/ex_cmds_defs.h" @@ -101,7 +101,7 @@ #include "nvim/os/fs.h" #include "nvim/os/os.h" #include "nvim/os/os_defs.h" -#include "nvim/os/pty_process.h" +#include "nvim/os/pty_proc.h" #include "nvim/os/shell.h" #include "nvim/os/stdpaths_defs.h" #include "nvim/os/time.h" @@ -3770,7 +3770,7 @@ static void f_jobpid(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) return; } - Process *proc = &data->stream.proc; + Proc *proc = &data->stream.proc; rettv->vval.v_number = proc->pid; } @@ -3796,13 +3796,13 @@ static void f_jobresize(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) return; } - if (data->stream.proc.type != kProcessTypePty) { + if (data->stream.proc.type != kProcTypePty) { emsg(_(e_channotpty)); return; } - pty_process_resize(&data->stream.pty, (uint16_t)argvars[1].vval.v_number, - (uint16_t)argvars[2].vval.v_number); + pty_proc_resize(&data->stream.pty, (uint16_t)argvars[1].vval.v_number, + (uint16_t)argvars[2].vval.v_number); rettv->vval.v_number = 1; } @@ -4077,7 +4077,7 @@ static void f_jobstop(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) // Ignore return code, but show error later. channel_close(data->id, kChannelPartRpc, &error); } - process_stop(&data->stream.proc); + proc_stop(&data->stream.proc); rettv->vval.v_number = 1; if (error) { emsg(error); @@ -4113,10 +4113,10 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) || !(chan = find_channel((uint64_t)TV_LIST_ITEM_TV(arg)->vval.v_number)) || chan->streamtype != kChannelStreamProc) { jobs[i] = NULL; // Invalid job. - } else if (process_is_stopped(&chan->stream.proc)) { + } else if (proc_is_stopped(&chan->stream.proc)) { // Job is stopped but not fully destroyed. // Ensure all callbacks on its event queue are executed. #15402 - process_wait(&chan->stream.proc, -1, NULL); + proc_wait(&chan->stream.proc, -1, NULL); jobs[i] = NULL; // Invalid job. } else { jobs[i] = chan; @@ -4144,8 +4144,8 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) if (jobs[i] == NULL) { continue; // Invalid job, will assign status=-3 below. } - int status = process_wait(&jobs[i]->stream.proc, remaining, - waiting_jobs); + int status = proc_wait(&jobs[i]->stream.proc, remaining, + waiting_jobs); if (status < 0) { break; // Interrupted (CTRL-C) or timeout, skip remaining jobs. } @@ -8207,7 +8207,7 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) return; } - int pid = chan->stream.pty.process.pid; + int pid = chan->stream.pty.proc.pid; // "./…" => "/home/foo/…" vim_FullName(cwd, NameBuff, sizeof(NameBuff), false); diff --git a/src/nvim/event/defs.h b/src/nvim/event/defs.h index 41690ead88..33e2f9cecb 100644 --- a/src/nvim/event/defs.h +++ b/src/nvim/event/defs.h @@ -142,30 +142,31 @@ struct socket_watcher { }; typedef enum { - kProcessTypeUv, - kProcessTypePty, -} ProcessType; + kProcTypeUv, + kProcTypePty, +} ProcType; -typedef struct process Process; -typedef void (*process_exit_cb)(Process *proc, int status, void *data); -typedef void (*internal_process_cb)(Process *proc); +/// OS process +typedef struct proc Proc; +typedef void (*proc_exit_cb)(Proc *proc, int status, void *data); +typedef void (*internal_proc_cb)(Proc *proc); -struct process { - ProcessType type; +struct proc { + ProcType type; Loop *loop; void *data; int pid, status, refcount; uint8_t exit_signal; // Signal used when killing (on Windows). - uint64_t stopped_time; // process_stop() timestamp + uint64_t stopped_time; // proc_stop() timestamp const char *cwd; char **argv; const char *exepath; dict_T *env; Stream in; RStream out, err; - /// Exit handler. If set, user must call process_free(). - process_exit_cb cb; - internal_process_cb internal_exit_cb, internal_close_cb; + /// Exit handler. If set, user must call proc_free(). + proc_exit_cb cb; + internal_proc_cb internal_exit_cb, internal_close_cb; bool closed, detach, overlapped, fwd_err; MultiQueue *events; }; diff --git a/src/nvim/event/libuv_process.c b/src/nvim/event/libuv_proc.c index 0dead1f9b4..5b445cdda7 100644 --- a/src/nvim/event/libuv_process.c +++ b/src/nvim/event/libuv_proc.c @@ -5,9 +5,9 @@ #include "nvim/eval/typval.h" #include "nvim/event/defs.h" -#include "nvim/event/libuv_process.h" +#include "nvim/event/libuv_proc.h" #include "nvim/event/loop.h" -#include "nvim/event/process.h" +#include "nvim/event/proc.h" #include "nvim/log.h" #include "nvim/os/os.h" #include "nvim/os/os_defs.h" @@ -15,15 +15,15 @@ #include "nvim/ui_client.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "event/libuv_process.c.generated.h" +# include "event/libuv_proc.c.generated.h" #endif /// @returns zero on success, or negative error code -int libuv_process_spawn(LibuvProcess *uvproc) +int libuv_proc_spawn(LibuvProc *uvproc) FUNC_ATTR_NONNULL_ALL { - Process *proc = (Process *)uvproc; - uvproc->uvopts.file = process_get_exepath(proc); + Proc *proc = (Proc *)uvproc; + uvproc->uvopts.file = proc_get_exepath(proc); uvproc->uvopts.args = proc->argv; uvproc->uvopts.flags = UV_PROCESS_WINDOWS_HIDE; #ifdef MSWIN @@ -101,7 +101,7 @@ int libuv_process_spawn(LibuvProcess *uvproc) return status; } -void libuv_process_close(LibuvProcess *uvproc) +void libuv_proc_close(LibuvProc *uvproc) FUNC_ATTR_NONNULL_ARG(1) { uv_close((uv_handle_t *)&uvproc->uv, close_cb); @@ -109,11 +109,11 @@ void libuv_process_close(LibuvProcess *uvproc) static void close_cb(uv_handle_t *handle) { - Process *proc = handle->data; + Proc *proc = handle->data; if (proc->internal_close_cb) { proc->internal_close_cb(proc); } - LibuvProcess *uvproc = (LibuvProcess *)proc; + LibuvProc *uvproc = (LibuvProc *)proc; if (uvproc->uvopts.env) { os_free_fullenv(uvproc->uvopts.env); } @@ -121,7 +121,7 @@ static void close_cb(uv_handle_t *handle) static void exit_cb(uv_process_t *handle, int64_t status, int term_signal) { - Process *proc = handle->data; + Proc *proc = handle->data; #if defined(MSWIN) // Use stored/expected signal. term_signal = proc->exit_signal; @@ -130,10 +130,10 @@ static void exit_cb(uv_process_t *handle, int64_t status, int term_signal) proc->internal_exit_cb(proc); } -LibuvProcess libuv_process_init(Loop *loop, void *data) +LibuvProc libuv_proc_init(Loop *loop, void *data) { - LibuvProcess rv = { - .process = process_init(loop, kProcessTypeUv, data) + LibuvProc rv = { + .proc = proc_init(loop, kProcTypeUv, data) }; return rv; } diff --git a/src/nvim/event/libuv_process.h b/src/nvim/event/libuv_proc.h index 12401dbb35..3127e166c0 100644 --- a/src/nvim/event/libuv_process.h +++ b/src/nvim/event/libuv_proc.h @@ -5,12 +5,12 @@ #include "nvim/event/defs.h" typedef struct { - Process process; + Proc proc; uv_process_t uv; uv_process_options_t uvopts; uv_stdio_container_t uvstdio[4]; -} LibuvProcess; +} LibuvProc; #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "event/libuv_process.h.generated.h" +# include "event/libuv_proc.h.generated.h" #endif diff --git a/src/nvim/event/process.c b/src/nvim/event/proc.c index 70fc31ba21..808bf794f0 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/proc.c @@ -4,24 +4,24 @@ #include <uv.h> #include "klib/klist.h" -#include "nvim/event/libuv_process.h" +#include "nvim/event/libuv_proc.h" #include "nvim/event/loop.h" #include "nvim/event/multiqueue.h" -#include "nvim/event/process.h" +#include "nvim/event/proc.h" #include "nvim/event/rstream.h" #include "nvim/event/stream.h" #include "nvim/event/wstream.h" #include "nvim/globals.h" #include "nvim/log.h" #include "nvim/main.h" -#include "nvim/os/process.h" -#include "nvim/os/pty_process.h" +#include "nvim/os/proc.h" +#include "nvim/os/pty_proc.h" #include "nvim/os/shell.h" #include "nvim/os/time.h" #include "nvim/ui_client.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "event/process.c.generated.h" +# include "event/proc.c.generated.h" #endif // Time for a process to exit cleanly before we send KILL. @@ -33,13 +33,13 @@ void __gcov_flush(void); #endif -static bool process_is_tearing_down = false; +static bool proc_is_tearing_down = false; // Delay exit until handles are closed, to avoid deadlocks static int exit_need_delay = 0; /// @returns zero on success, or negative error code -int process_spawn(Process *proc, bool in, bool out, bool err) +int proc_spawn(Proc *proc, bool in, bool out, bool err) FUNC_ATTR_NONNULL_ALL { // forwarding stderr contradicts with processing it internally @@ -70,11 +70,11 @@ int process_spawn(Process *proc, bool in, bool out, bool err) int status; switch (proc->type) { - case kProcessTypeUv: - status = libuv_process_spawn((LibuvProcess *)proc); + case kProcTypeUv: + status = libuv_proc_spawn((LibuvProc *)proc); break; - case kProcessTypePty: - status = pty_process_spawn((PtyProcess *)proc); + case kProcTypePty: + status = pty_proc_spawn((PtyProc *)proc); break; } @@ -89,12 +89,12 @@ int process_spawn(Process *proc, bool in, bool out, bool err) uv_close((uv_handle_t *)&proc->err.s.uv.pipe, NULL); } - if (proc->type == kProcessTypeUv) { - uv_close((uv_handle_t *)&(((LibuvProcess *)proc)->uv), NULL); + if (proc->type == kProcTypeUv) { + uv_close((uv_handle_t *)&(((LibuvProc *)proc)->uv), NULL); } else { - process_close(proc); + proc_close(proc); } - process_free(proc); + proc_free(proc); proc->status = -1; return status; } @@ -102,52 +102,52 @@ int process_spawn(Process *proc, bool in, bool out, bool err) if (in) { stream_init(NULL, &proc->in, -1, (uv_stream_t *)&proc->in.uv.pipe); proc->in.internal_data = proc; - proc->in.internal_close_cb = on_process_stream_close; + proc->in.internal_close_cb = on_proc_stream_close; proc->refcount++; } if (out) { stream_init(NULL, &proc->out.s, -1, (uv_stream_t *)&proc->out.s.uv.pipe); proc->out.s.internal_data = proc; - proc->out.s.internal_close_cb = on_process_stream_close; + proc->out.s.internal_close_cb = on_proc_stream_close; proc->refcount++; } if (err) { stream_init(NULL, &proc->err.s, -1, (uv_stream_t *)&proc->err.s.uv.pipe); proc->err.s.internal_data = proc; - proc->err.s.internal_close_cb = on_process_stream_close; + proc->err.s.internal_close_cb = on_proc_stream_close; proc->refcount++; } - proc->internal_exit_cb = on_process_exit; + proc->internal_exit_cb = on_proc_exit; proc->internal_close_cb = decref; proc->refcount++; kl_push(WatcherPtr, proc->loop->children, proc); - DLOG("new: pid=%d exepath=[%s]", proc->pid, process_get_exepath(proc)); + DLOG("new: pid=%d exepath=[%s]", proc->pid, proc_get_exepath(proc)); return 0; } -void process_teardown(Loop *loop) FUNC_ATTR_NONNULL_ALL +void proc_teardown(Loop *loop) FUNC_ATTR_NONNULL_ALL { - process_is_tearing_down = true; + proc_is_tearing_down = true; kl_iter(WatcherPtr, loop->children, current) { - Process *proc = (*current)->data; - if (proc->detach || proc->type == kProcessTypePty) { + Proc *proc = (*current)->data; + if (proc->detach || proc->type == kProcTypePty) { // Close handles to process without killing it. - CREATE_EVENT(loop->events, process_close_handles, proc); + CREATE_EVENT(loop->events, proc_close_handles, proc); } else { - process_stop(proc); + proc_stop(proc); } } // Wait until all children exit and all close events are processed. LOOP_PROCESS_EVENTS_UNTIL(loop, loop->events, -1, kl_empty(loop->children) && multiqueue_empty(loop->events)); - pty_process_teardown(loop); + pty_proc_teardown(loop); } -void process_close_streams(Process *proc) FUNC_ATTR_NONNULL_ALL +void proc_close_streams(Proc *proc) FUNC_ATTR_NONNULL_ALL { wstream_may_close(&proc->in); rstream_may_close(&proc->out); @@ -162,7 +162,7 @@ void process_close_streams(Process *proc) FUNC_ATTR_NONNULL_ALL /// @return Exit code of the process. proc->status will have the same value. /// -1 if the timeout expired while the process is still running. /// -2 if the user interrupted the wait. -int process_wait(Process *proc, int ms, MultiQueue *events) +int proc_wait(Proc *proc, int ms, MultiQueue *events) FUNC_ATTR_NONNULL_ARG(1) { if (!proc->refcount) { @@ -186,7 +186,7 @@ int process_wait(Process *proc, int ms, MultiQueue *events) // Assume that a user hitting CTRL-C does not like the current job. Kill it. if (got_int) { got_int = false; - process_stop(proc); + proc_stop(proc); if (ms == -1) { // We can only return if all streams/handles are closed and the job // exited. @@ -214,7 +214,7 @@ int process_wait(Process *proc, int ms, MultiQueue *events) } /// Ask a process to terminate and eventually kill if it doesn't respond -void process_stop(Process *proc) FUNC_ATTR_NONNULL_ALL +void proc_stop(Proc *proc) FUNC_ATTR_NONNULL_ALL { bool exited = (proc->status >= 0); if (exited || proc->stopped_time) { @@ -224,13 +224,13 @@ void process_stop(Process *proc) FUNC_ATTR_NONNULL_ALL proc->exit_signal = SIGTERM; switch (proc->type) { - case kProcessTypeUv: + case kProcTypeUv: os_proc_tree_kill(proc->pid, SIGTERM); break; - case kProcessTypePty: + case kProcTypePty: // close all streams for pty processes to send SIGHUP to the process - process_close_streams(proc); - pty_process_close_master((PtyProcess *)proc); + proc_close_streams(proc); + pty_proc_close_master((PtyProc *)proc); break; } @@ -240,7 +240,7 @@ void process_stop(Process *proc) FUNC_ATTR_NONNULL_ALL } /// Frees process-owned resources. -void process_free(Process *proc) FUNC_ATTR_NONNULL_ALL +void proc_free(Proc *proc) FUNC_ATTR_NONNULL_ALL { if (proc->argv != NULL) { shell_free_argv(proc->argv); @@ -249,19 +249,19 @@ void process_free(Process *proc) FUNC_ATTR_NONNULL_ALL } /// Sends SIGKILL (or SIGTERM..SIGKILL for PTY jobs) to processes that did -/// not terminate after process_stop(). +/// not terminate after proc_stop(). static void children_kill_cb(uv_timer_t *handle) { Loop *loop = handle->loop->data; kl_iter(WatcherPtr, loop->children, current) { - Process *proc = (*current)->data; + Proc *proc = (*current)->data; bool exited = (proc->status >= 0); if (exited || !proc->stopped_time) { continue; } uint64_t term_sent = UINT64_MAX == proc->stopped_time; - if (kProcessTypePty != proc->type || term_sent) { + if (kProcTypePty != proc->type || term_sent) { proc->exit_signal = SIGKILL; os_proc_tree_kill(proc->pid, SIGKILL); } else { @@ -275,19 +275,19 @@ static void children_kill_cb(uv_timer_t *handle) } } -static void process_close_event(void **argv) +static void proc_close_event(void **argv) { - Process *proc = argv[0]; + Proc *proc = argv[0]; if (proc->cb) { // User (hint: channel_job_start) is responsible for calling - // process_free(). + // proc_free(). proc->cb(proc, proc->status, proc->data); } else { - process_free(proc); + proc_free(proc); } } -static void decref(Process *proc) +static void decref(Proc *proc) { if (--proc->refcount != 0) { return; @@ -303,13 +303,13 @@ static void decref(Process *proc) } assert(node); kl_shift_at(WatcherPtr, loop->children, node); - CREATE_EVENT(proc->events, process_close_event, proc); + CREATE_EVENT(proc->events, proc_close_event, proc); } -static void process_close(Process *proc) +static void proc_close(Proc *proc) FUNC_ATTR_NONNULL_ARG(1) { - if (process_is_tearing_down && (proc->detach || proc->type == kProcessTypePty) + if (proc_is_tearing_down && (proc->detach || proc->type == kProcTypePty) && proc->closed) { // If a detached/pty process dies while tearing down it might get closed // twice. @@ -319,17 +319,17 @@ static void process_close(Process *proc) proc->closed = true; if (proc->detach) { - if (proc->type == kProcessTypeUv) { - uv_unref((uv_handle_t *)&(((LibuvProcess *)proc)->uv)); + if (proc->type == kProcTypeUv) { + uv_unref((uv_handle_t *)&(((LibuvProc *)proc)->uv)); } } switch (proc->type) { - case kProcessTypeUv: - libuv_process_close((LibuvProcess *)proc); + case kProcTypeUv: + libuv_proc_close((LibuvProc *)proc); break; - case kProcessTypePty: - pty_process_close((PtyProcess *)proc); + case kProcTypePty: + pty_proc_close((PtyProc *)proc); break; } } @@ -338,7 +338,7 @@ static void process_close(Process *proc) /// /// @param proc Process, for which an output stream should be flushed. /// @param stream Stream to flush. -static void flush_stream(Process *proc, RStream *stream) +static void flush_stream(Proc *proc, RStream *stream) FUNC_ATTR_NONNULL_ARG(1) { if (!stream || stream->s.closed) { @@ -382,16 +382,16 @@ static void flush_stream(Process *proc, RStream *stream) } } -static void process_close_handles(void **argv) +static void proc_close_handles(void **argv) { - Process *proc = argv[0]; + Proc *proc = argv[0]; exit_need_delay++; flush_stream(proc, &proc->out); flush_stream(proc, &proc->err); - process_close_streams(proc); - process_close(proc); + proc_close_streams(proc); + proc_close(proc); exit_need_delay--; } @@ -426,7 +426,7 @@ void exit_from_channel(int status) multiqueue_put(main_loop.fast_events, exit_event, (void *)(intptr_t)status); } -static void on_process_exit(Process *proc) +static void on_proc_exit(Proc *proc) { Loop *loop = proc->loop; ILOG("exited: pid=%d status=%d stoptime=%" PRIu64, proc->pid, proc->status, @@ -439,13 +439,13 @@ static |