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/os | |
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/os')
-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 |
11 files changed, 97 insertions, 97 deletions
diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index 8dfedd073e..ccf6c9554a 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -344,7 +344,7 @@ char *os_getenvname_at_index(size_t index) #endif } -/// Get the process ID of the Neovim process. +/// Get the process ID of the Nvim process. /// /// @return the process ID. int64_t os_get_pid(void) diff --git a/src/nvim/os/process.c b/src/nvim/os/proc.c index e8d38d5b8a..1670e469ee 100644 --- a/src/nvim/os/process.c +++ b/src/nvim/os/proc.c @@ -37,24 +37,24 @@ #include "nvim/log.h" #include "nvim/memory.h" -#include "nvim/os/process.h" +#include "nvim/os/proc.h" #ifdef MSWIN # include "nvim/api/private/helpers.h" #endif #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "os/process.c.generated.h" +# include "os/proc.c.generated.h" #endif #ifdef MSWIN -static bool os_proc_tree_kill_rec(HANDLE process, int sig) +static bool os_proc_tree_kill_rec(HANDLE proc, int sig) { - if (process == NULL) { + if (proc == NULL) { return false; } PROCESSENTRY32 pe; - DWORD pid = GetProcessId(process); + DWORD pid = GetProcessId(proc); if (pid != 0) { HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); @@ -77,7 +77,7 @@ static bool os_proc_tree_kill_rec(HANDLE process, int sig) } theend: - return (bool)TerminateProcess(process, (unsigned)sig); + return (bool)TerminateProcess(proc, (unsigned)sig); } /// Kills process `pid` and its descendants recursively. bool os_proc_tree_kill(int pid, int sig) diff --git a/src/nvim/os/process.h b/src/nvim/os/proc.h index 3b116b4bad..1831f21cc3 100644 --- a/src/nvim/os/process.h +++ b/src/nvim/os/proc.h @@ -7,5 +7,5 @@ #endif #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "os/process.h.generated.h" +# include "os/proc.h.generated.h" #endif diff --git a/src/nvim/os/pty_conpty_win.c b/src/nvim/os/pty_conpty_win.c index e7697880af..6402330a52 100644 --- a/src/nvim/os/pty_conpty_win.c +++ b/src/nvim/os/pty_conpty_win.c @@ -143,7 +143,7 @@ finished: return conpty_object; } -bool os_conpty_spawn(conpty_t *conpty_object, HANDLE *process_handle, wchar_t *name, +bool os_conpty_spawn(conpty_t *conpty_object, HANDLE *proc_handle, wchar_t *name, wchar_t *cmd_line, wchar_t *cwd, wchar_t *env) { PROCESS_INFORMATION pi = { 0 }; @@ -159,7 +159,7 @@ bool os_conpty_spawn(conpty_t *conpty_object, HANDLE *process_handle, wchar_t *n &pi)) { return false; } - *process_handle = pi.hProcess; + *proc_handle = pi.hProcess; return true; } diff --git a/src/nvim/os/pty_proc.h b/src/nvim/os/pty_proc.h new file mode 100644 index 0000000000..d815aae69c --- /dev/null +++ b/src/nvim/os/pty_proc.h @@ -0,0 +1,7 @@ +#pragma once + +#ifdef MSWIN +# include "nvim/os/pty_proc_win.h" +#else +# include "nvim/os/pty_proc_unix.h" +#endif diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_proc_unix.c index cfa4dcada7..9e9303ed48 100644 --- a/src/nvim/os/pty_process_unix.c +++ b/src/nvim/os/pty_proc_unix.c @@ -34,16 +34,16 @@ #include "nvim/eval/typval.h" #include "nvim/event/defs.h" #include "nvim/event/loop.h" -#include "nvim/event/process.h" +#include "nvim/event/proc.h" #include "nvim/log.h" #include "nvim/os/fs.h" #include "nvim/os/os_defs.h" -#include "nvim/os/pty_process.h" -#include "nvim/os/pty_process_unix.h" +#include "nvim/os/pty_proc.h" +#include "nvim/os/pty_proc_unix.h" #include "nvim/types_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "os/pty_process_unix.c.generated.h" +# include "os/pty_proc_unix.c.generated.h" #endif #if defined(__sun) && !defined(HAVE_FORKPTY) @@ -158,7 +158,7 @@ static pid_t forkpty(int *amaster, char *name, struct termios *termp, struct win #endif /// @returns zero on success, or negative error code -int pty_process_spawn(PtyProcess *ptyproc) +int pty_proc_spawn(PtyProc *ptyproc) FUNC_ATTR_NONNULL_ALL { // termios initialized at first use @@ -168,7 +168,7 @@ int pty_process_spawn(PtyProcess *ptyproc) } int status = 0; // zero or negative error code (libuv convention) - Process *proc = (Process *)ptyproc; + Proc *proc = (Proc *)ptyproc; assert(proc->err.s.closed); uv_signal_start(&proc->loop->children_watcher, chld_handler, SIGCHLD); ptyproc->winsize = (struct winsize){ ptyproc->height, ptyproc->width, 0, 0 }; @@ -224,29 +224,29 @@ error: return status; } -const char *pty_process_tty_name(PtyProcess *ptyproc) +const char *pty_proc_tty_name(PtyProc *ptyproc) { return ptsname(ptyproc->tty_fd); } -void pty_process_resize(PtyProcess *ptyproc, uint16_t width, uint16_t height) +void pty_proc_resize(PtyProc *ptyproc, uint16_t width, uint16_t height) FUNC_ATTR_NONNULL_ALL { ptyproc->winsize = (struct winsize){ height, width, 0, 0 }; ioctl(ptyproc->tty_fd, TIOCSWINSZ, &ptyproc->winsize); } -void pty_process_close(PtyProcess *ptyproc) +void pty_proc_close(PtyProc *ptyproc) FUNC_ATTR_NONNULL_ALL { - pty_process_close_master(ptyproc); - Process *proc = (Process *)ptyproc; + pty_proc_close_master(ptyproc); + Proc *proc = (Proc *)ptyproc; if (proc->internal_close_cb) { proc->internal_close_cb(proc); } } -void pty_process_close_master(PtyProcess *ptyproc) FUNC_ATTR_NONNULL_ALL +void pty_proc_close_master(PtyProc *ptyproc) FUNC_ATTR_NONNULL_ALL { if (ptyproc->tty_fd >= 0) { close(ptyproc->tty_fd); @@ -254,12 +254,12 @@ void pty_process_close_master(PtyProcess *ptyproc) FUNC_ATTR_NONNULL_ALL } } -void pty_process_teardown(Loop *loop) +void pty_proc_teardown(Loop *loop) { uv_signal_stop(&loop->children_watcher); } -static void init_child(PtyProcess *ptyproc) +static void init_child(PtyProc *ptyproc) FUNC_ATTR_NONNULL_ALL { #if defined(HAVE__NSGETENVIRON) @@ -277,13 +277,13 @@ static void init_child(PtyProcess *ptyproc) signal(SIGTERM, SIG_DFL); signal(SIGALRM, SIG_DFL); - Process *proc = (Process *)ptyproc; + Proc *proc = (Proc *)ptyproc; if (proc->cwd && os_chdir(proc->cwd) != 0) { ELOG("chdir(%s) failed: %s", proc->cwd, strerror(errno)); return; } - const char *prog = process_get_exepath(proc); + const char *prog = proc_get_exepath(proc); assert(proc->env); environ = tv_dict_to_env(proc->env); @@ -388,7 +388,7 @@ static void chld_handler(uv_signal_t *handle, int signum) Loop *loop = handle->loop->data; kl_iter(WatcherPtr, loop->children, current) { - Process *proc = (*current)->data; + Proc *proc = (*current)->data; do { pid = waitpid(proc->pid, &stat, WNOHANG); } while (pid < 0 && errno == EINTR); @@ -406,10 +406,10 @@ static void chld_handler(uv_signal_t *handle, int signum) } } -PtyProcess pty_process_init(Loop *loop, void *data) +PtyProc pty_proc_init(Loop *loop, void *data) { - PtyProcess rv; - rv.process = process_init(loop, kProcessTypePty, data); + PtyProc rv; + rv.proc = proc_init(loop, kProcTypePty, data); rv.width = 80; rv.height = 24; rv.tty_fd = -1; diff --git a/src/nvim/os/pty_process_unix.h b/src/nvim/os/pty_proc_unix.h index 1a77ae5fd5..47f9af088e 100644 --- a/src/nvim/os/pty_process_unix.h +++ b/src/nvim/os/pty_proc_unix.h @@ -1,5 +1,5 @@ #pragma once -// IWYU pragma: private, include "nvim/os/pty_process.h" +// IWYU pragma: private, include "nvim/os/pty_proc.h" #include <stdint.h> #include <sys/ioctl.h> @@ -7,12 +7,12 @@ #include "nvim/event/defs.h" typedef struct { - Process process; + Proc proc; uint16_t width, height; struct winsize winsize; int tty_fd; -} PtyProcess; +} PtyProc; #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "os/pty_process_unix.h.generated.h" +# include "os/pty_proc_unix.h.generated.h" #endif diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_proc_win.c index 39c3966c1c..5bd6eead51 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_proc_win.c @@ -10,20 +10,20 @@ #include "nvim/memory.h" #include "nvim/os/os.h" #include "nvim/os/pty_conpty_win.h" -#include "nvim/os/pty_process_win.h" +#include "nvim/os/pty_proc_win.h" #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "os/pty_process_win.c.generated.h" +# include "os/pty_proc_win.c.generated.h" #endif -static void CALLBACK pty_process_finish1(void *context, BOOLEAN unused) +static void CALLBACK pty_proc_finish1(void *context, BOOLEAN unused) FUNC_ATTR_NONNULL_ALL { - PtyProcess *ptyproc = (PtyProcess *)context; - Process *proc = (Process *)ptyproc; + PtyProc *ptyproc = (PtyProc *)context; + Proc *proc = (Proc *)ptyproc; os_conpty_free(ptyproc->conpty); - // NB: pty_process_finish1() is called on a separate thread, + // NB: pty_proc_finish1() is called on a separate thread, // but the timer only works properly if it's started by the main thread. loop_schedule_fast(proc->loop, event_create(start_wait_eof_timer, ptyproc)); } @@ -31,7 +31,7 @@ static void CALLBACK pty_process_finish1(void *context, BOOLEAN unused) static void start_wait_eof_timer(void **argv) FUNC_ATTR_NONNULL_ALL { - PtyProcess *ptyproc = (PtyProcess *)argv[0]; + PtyProc *ptyproc = (PtyProc *)argv[0]; if (ptyproc->finish_wait != NULL) { uv_timer_start(&ptyproc->wait_eof_timer, wait_eof_timer_cb, 200, 200); @@ -39,15 +39,15 @@ static void start_wait_eof_timer(void **argv) } /// @returns zero on success, or negative error code. -int pty_process_spawn(PtyProcess *ptyproc) +int pty_proc_spawn(PtyProc *ptyproc) FUNC_ATTR_NONNULL_ALL { - Process *proc = (Process *)ptyproc; + Proc *proc = (Proc *)ptyproc; int status = 0; conpty_t *conpty_object = NULL; char *in_name = NULL; char *out_name = NULL; - HANDLE process_handle = NULL; + HANDLE proc_handle = NULL; uv_connect_t *in_req = NULL; uv_connect_t *out_req = NULL; wchar_t *cmd_line = NULL; @@ -69,7 +69,7 @@ int pty_process_spawn(PtyProcess *ptyproc) uv_pipe_connect(in_req, &proc->in.uv.pipe, in_name, - pty_process_connect_cb); + pty_proc_connect_cb); } if (!proc->out.s.closed) { @@ -77,7 +77,7 @@ int pty_process_spawn(PtyProcess *ptyproc) uv_pipe_connect(out_req, &proc->out.s.uv.pipe, out_name, - pty_process_connect_cb); + pty_proc_connect_cb); } if (proc->cwd != NULL) { @@ -105,7 +105,7 @@ int pty_process_spawn(PtyProcess *ptyproc) } if (!os_conpty_spawn(conpty_object, - &process_handle, + &proc_handle, NULL, cmd_line, cwd, @@ -114,42 +114,42 @@ int pty_process_spawn(PtyProcess *ptyproc) status = (int)GetLastError(); goto cleanup; } - proc->pid = (int)GetProcessId(process_handle); + proc->pid = (int)GetProcessId(proc_handle); uv_timer_init(&proc->loop->uv, &ptyproc->wait_eof_timer); ptyproc->wait_eof_timer.data = (void *)ptyproc; if (!RegisterWaitForSingleObject(&ptyproc->finish_wait, - process_handle, - pty_process_finish1, + proc_handle, + pty_proc_finish1, ptyproc, INFINITE, WT_EXECUTEDEFAULT | WT_EXECUTEONLYONCE)) { abort(); } - // Wait until pty_process_connect_cb is called. + // Wait until pty_proc_connect_cb is called. while ((in_req != NULL && in_req->handle != NULL) || (out_req != NULL && out_req->handle != NULL)) { uv_run(&proc->loop->uv, UV_RUN_ONCE); } ptyproc->conpty = conpty_object; - ptyproc->process_handle = process_handle; + ptyproc->proc_handle = proc_handle; conpty_object = NULL; - process_handle = NULL; + proc_handle = NULL; cleanup: if (status) { // In the case of an error of MultiByteToWideChar or CreateProcessW. - ELOG("pty_process_spawn(%s): %s: error code: %d", + ELOG("pty_proc_spawn(%s): %s: error code: %d", proc->argv[0], emsg, status); status = os_translate_sys_error(status); } os_conpty_free(conpty_object); xfree(in_name); xfree(out_name); - if (process_handle != NULL) { - CloseHandle(process_handle); + if (proc_handle != NULL) { + CloseHandle(proc_handle); } xfree(in_req); xfree(out_req); @@ -159,32 +159,32 @@ cleanup: return status; } -const char *pty_process_tty_name(PtyProcess *ptyproc) +const char *pty_proc_tty_name(PtyProc *ptyproc) { return "?"; } -void pty_process_resize(PtyProcess *ptyproc, uint16_t width, uint16_t height) +void pty_proc_resize(PtyProc *ptyproc, uint16_t width, uint16_t height) FUNC_ATTR_NONNULL_ALL { os_conpty_set_size(ptyproc->conpty, width, height); } -void pty_process_close(PtyProcess *ptyproc) +void pty_proc_close(PtyProc *ptyproc) FUNC_ATTR_NONNULL_ALL { - Process *proc = (Process *)ptyproc; + Proc *proc = (Proc *)ptyproc; - pty_process_close_master(ptyproc); + pty_proc_close_master(ptyproc); if (ptyproc->finish_wait != NULL) { UnregisterWaitEx(ptyproc->finish_wait, NULL); ptyproc->finish_wait = NULL; uv_close((uv_handle_t *)&ptyproc->wait_eof_timer, NULL); } - if (ptyproc->process_handle != NULL) { - CloseHandle(ptyproc->process_handle); - ptyproc->process_handle = NULL; + if (ptyproc->proc_handle != NULL) { + CloseHandle(ptyproc->proc_handle); + ptyproc->proc_handle = NULL; } if (proc->internal_close_cb) { @@ -192,17 +192,17 @@ void pty_process_close(PtyProcess *ptyproc) } } -void pty_process_close_master(PtyProcess *ptyproc) +void pty_proc_close_master(PtyProc *ptyproc) FUNC_ATTR_NONNULL_ALL { } -void pty_process_teardown(Loop *loop) +void pty_proc_teardown(Loop *loop) FUNC_ATTR_NONNULL_ALL { } -static void pty_process_connect_cb(uv_connect_t *req, int status) +static void pty_proc_connect_cb(uv_connect_t *req, int status) FUNC_ATTR_NONNULL_ALL { assert(status == 0); @@ -212,23 +212,23 @@ static void pty_process_connect_cb(uv_connect_t *req, int status) static void wait_eof_timer_cb(uv_timer_t *wait_eof_timer) FUNC_ATTR_NONNULL_ALL { - PtyProcess *ptyproc = wait_eof_timer->data; - Process *proc = (Process *)ptyproc; + PtyProc *ptyproc = wait_eof_timer->data; + Proc *proc = (Proc *)ptyproc; assert(ptyproc->finish_wait != NULL); if (proc->out.s.closed || proc->out.did_eof || !uv_is_readable(proc->out.s.uvstream)) { uv_timer_stop(&ptyproc->wait_eof_timer); - pty_process_finish2(ptyproc); + pty_proc_finish2(ptyproc); } } -static void pty_process_finish2(PtyProcess *ptyproc) +static void pty_proc_finish2(PtyProc *ptyproc) FUNC_ATTR_NONNULL_ALL { - Process *proc = (Process *)ptyproc; + Proc *proc = (Proc *)ptyproc; DWORD exit_code = 0; - GetExitCodeProcess(ptyproc->process_handle, &exit_code); + GetExitCodeProcess(ptyproc->proc_handle, &exit_code); proc->status = proc->exit_signal ? 128 + proc->exit_signal : (int)exit_code; proc->internal_exit_cb(proc); @@ -427,14 +427,14 @@ cleanup: return rc; } -PtyProcess pty_process_init(Loop *loop, void *data) +PtyProc pty_proc_init(Loop *loop, void *data) { - PtyProcess rv; - rv.process = process_init(loop, kProcessTypePty, data); + PtyProc rv; + rv.proc = proc_init(loop, kProcTypePty, data); rv.width = 80; rv.height = 24; rv.conpty = NULL; rv.finish_wait = NULL; - rv.process_handle = NULL; + rv.proc_handle = NULL; return rv; } diff --git a/src/nvim/os/pty_process_win.h b/src/nvim/os/pty_proc_win.h index 3528f6bfe5..c2fdea506e 100644 --- a/src/nvim/os/pty_process_win.h +++ b/src/nvim/os/pty_proc_win.h @@ -1,20 +1,20 @@ #pragma once -// IWYU pragma: private, include "nvim/os/pty_process.h" +// IWYU pragma: private, include "nvim/os/pty_proc.h" #include <uv.h> -#include "nvim/event/process.h" +#include "nvim/event/proc.h" #include "nvim/lib/queue_defs.h" #include "nvim/os/pty_conpty_win.h" typedef struct pty_process { - Process process; + Proc proc; uint16_t width, height; conpty_t *conpty; HANDLE finish_wait; - HANDLE process_handle; + HANDLE proc_handle; uv_timer_t wait_eof_timer; -} PtyProcess; +} PtyProc; // Structure used by build_cmd_line() typedef struct arg_node { @@ -23,5 +23,5 @@ typedef struct arg_node { } ArgNode; #ifdef INCLUDE_GENERATED_DECLARATIONS -# include "os/pty_process_win.h.generated.h" +# include "os/pty_proc_win.h.generated.h" #endif diff --git a/src/nvim/os/pty_process.h b/src/nvim/os/pty_process.h deleted file mode 100644 index 2c7a5f66bd..0000000000 --- a/src/nvim/os/pty_process.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#ifdef MSWIN -# include "nvim/os/pty_process_win.h" -#else -# include "nvim/os/pty_process_unix.h" -#endif diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 0b082c164d..a1ec9449df 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -14,10 +14,10 @@ #include "nvim/eval.h" #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/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" @@ -872,12 +872,12 @@ static int do_os_system(char **argv, const char *input, size_t len, char **outpu char prog[MAXPATHL]; xstrlcpy(prog, argv[0], MAXPATHL); - LibuvProcess uvproc = libuv_process_init(&main_loop, &buf); - Process *proc = &uvproc.process; + LibuvProc uvproc = libuv_proc_init(&main_loop, &buf); + Proc *proc = &uvproc.proc; MultiQueue *events = multiqueue_new_child(main_loop.events); proc->events = events; proc->argv = argv; - int status = process_spawn(proc, has_input, true, true); + int status = proc_spawn(proc, has_input, true, true); if (status) { loop_poll_events(&main_loop, 0); // Failed, probably 'shell' is not executable. @@ -910,7 +910,7 @@ static int do_os_system(char **argv, const char *input, size_t len, char **outpu if (!wstream_write(&proc->in, input_buffer)) { // couldn't write, stop the process and tell the user about it - process_stop(proc); + proc_stop(proc); return -1; } // close the input stream after everything is written @@ -927,7 +927,7 @@ static int do_os_system(char **argv, const char *input, size_t len, char **outpu msg_no_more = true; lines_left = -1; } - int exitcode = process_wait(proc, -1, NULL); + int exitcode = proc_wait(proc, -1, NULL); if (!got_int && out_data_decide_throttle(0)) { // Last chunk of output was skipped; display it now. out_data_ring(NULL, SIZE_MAX); |