aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/event/proc.c
Commit message (Collapse)AuthorAge
* revert: "refactor(process): don't read from PTY master using uv_pipe_t" (#37401)zeertzjq2026-03-30
| | | This reverts commit 75c8f755015e4724ba45bd84137d41efa40a3025.
* fix(:restart): formalize restart event #35223Sathya Pramodh2026-03-28
| | | | | | | | | | | | | | | | | | | Problem: The "restart" event has some problems: - all UI clients must implement a somewhat complex set of setups - UI must be on the same machine as the server - only works for the "current" UI - race/edge case: If the user config has errors / waiting for input, are all UIs able to attach while Nvim is waiting for input? Solution: - Perform the restart on the server, not the client. - Pass listen address (instead of CLI args) in the UI event. - Simplifies UI logic: they only need to attach to new address. - Opens the door for more enhancements in the future, such as allowing all UIs to reattach instead of only the "current" UI. Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* fix(process): wrong exit code for SIGHUP on Windows (#38242)zeertzjq2026-03-12
| | | | | | | | | Problem: When stopping a PTY process on Windows, the exit code indicates that the process is stopped by SIGTERM even when closing all streams is enough to terminate the process. This is inconsistent with other platforms. Solution: Set exit_signal to SIGHUP instead of SIGTERM when using SIGHUP.
* revert: "fix(tui): server --listen error sometimes not visible (#38027)" ↵zeertzjq2026-03-06
| | | | | | | | (#38175) This reverts commit ab8371a26cf47a40d26af637455ea71da0d5a59d. Need to think of a different solution, which may require adding new flags to nvim_ui_attach() (e.g. passing stdout or stderr fd).
* fix(tui): server --listen error sometimes not visible (#38027)zeertzjq2026-03-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: If Nvim server fails to --listen and prints error before the TUI enters alternate screen, the error isn't visible. Solution: Forward server stderr using client side stderr handler instead of having the server inherit client stderr file descriptor. This does mean that `stderr_isatty` will be `false` in the server, but that value doesn't matter in embedded mode. Always pass `stdin_fd` to embedded server to avoid a hang when reading from stdin when it's a TTY (not sure why one wants to do that, perhaps by mistake), because if `stdin_fd` isn't passed, the server will try to use stderr as stdin. Example test failure on CI: FAILED test/functional/terminal/tui_spec.lua @ 41: TUI exit status 1 and error message with server --listen error #34365 test/functional/terminal\tui_spec.lua:55: Failed to match any screen lines. Expected (anywhere): "nvim%.exe: Failed to %-%-listen: address already in use:" Actual: |{114:nvim.exe -h"} | | | |[Process exited 1]^ | | | | | | | | | | | | | | | | | | | | | | | | | | | |{5:-- TERMINAL --} | Snapshot: screen:expect([[ {114:nvim.exe -h"} | | [Process exited 1]^ | |*13 {5:-- TERMINAL --} | ]]) stack traceback: test\functional\ui\screen.lua:909: in function '_wait' test\functional\ui\screen.lua:537: in function 'expect' test/functional/terminal\tui_spec.lua:55: in function <test/functional/terminal\tui_spec.lua:41> In this case, it appears that the client entered alternate screen in the middle of the server's print_mainerr().
* fix(process): handle poll() interrupted by a signal (#38024)zeertzjq2026-02-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is indeed possible that a signal may arrive during flush_stream() (e.g. SIGCHLD from another child process), so poll() again on EINTR. Fixes the following Coverity warning: _____________________________________________________________________________________________ *** CID 644345: Error handling issues (CHECKED_RETURN) /src/nvim/event/proc.c: 405 in flush_stream() 399 400 #ifdef __linux__ 401 // On Linux, libuv's polling (which uses epoll) doesn't flush PTY master's pending 402 // work on kernel workqueue, so use an explcit poll() before that. #37982 403 if (proc->type == kProcTypePty && !stream->did_eof) { 404 struct pollfd pollfd = { .fd = ((PtyProc *)proc)->tty_fd, .events = POLLIN }; >>> CID 644345: Error handling issues (CHECKED_RETURN) >>> Calling "poll(&pollfd, 1UL, 0)" without checking return value. This library function may fail and return an error code. 405 poll(&pollfd, 1, 0); 406 } 407 #endif 408 // Poll for data and process the generated events. 409 loop_poll_events(proc->loop, 0); 410 if (stream->s.events) { Another possible error is ENOMEM, which is probably not worth handling. For reference, #23308 previously removed a case of ENOMEM handling, and this PR also removes an outdated mention of that. Also reduce the number of #ifdefs in non-OS-specific files.
* fix(process): use poll() to drain PTY master on Linux (#38005)zeertzjq2026-02-23
| | | | On Linux, libuv's polling (which uses epoll) doesn't flush PTY master's pending work on kernel workqueue, so use an explicit poll() before that.
* fix(process): don't limit PTY master remaining data sizezeertzjq2026-01-15
|
* refactor(process): don't read from PTY master using uv_pipe_tzeertzjq2026-01-15
| | | | | | | | | Using uv_pipe_t to read from PTY master may drop data if the PTY process exits immediately after output, as libuv treats a partial read after POLLHUP as EOF, which isn't true for PTY master on Linux. Therefore use uv_poll_t instead. This commit can be reverted if libuv/libuv#4992 is fixed for uv_pipe_t.
* Merge pull request #36393 from zeertzjq/rstream-close-cbzeertzjq2025-10-31
| | | fix(channel): closing socket with pending writes leaks memory
* refactor(build): remove INCLUDE_GENERATED_DECLARATIONS guardsbfredl2025-08-14
| | | | | | | | | These are not needed after #35129 but making uncrustify still play nice with them was a bit tricky. Unfortunately `uncrustify --update-config-with-doc` breaks strings with backslashes. This issue has been reported upstream, and in the meanwhile auto-update on every single run has been disabled.
* fix(tui): wait for embedded server's exit codezeertzjq2025-06-10
| | | | | | Uses the undocumented "error_exit" UI event for a different purpose: When :detach is used on the server, send an "error_exit" with 0 `status` to indicate that the server shouldn't wait for client exit.
* fix(mswin): UI may hang on exitJustin M. Keyes2025-03-25
| | | | | | | | | Problem: On Windows, since b360c0608556, UI may hang on exit. #33019 Solution: Restore the hack in on_proc_exit, until we can figure out why rpc_close is not called in the UI client when the server closes the channel.
* refactor(channel): eliminate special case in on_proc_exit() #32485Justin M. Keyes2025-02-17
| | | | | | | | | | | Problem: on_proc_exit() has a special-case that assumes that the UI client will never spawn more than 1 child process. Solution: If the Nvim server exits, the stream EOF will trigger `rpc_close()` in the UI client, so we don't need the special case in `on_proc_exit`. Pass `Channel.exit_status` from `rpc_close()` so that the correct exit code is reflected.
* fix(ui): Windows :detach is opt-inJustin M. Keyes2025-02-10
| | | | | | | | | Problem: On Windows, spawning the `nvim --embed` server with `detach=true` breaks various `tt.setup_child_nvim` tests. Solution: Make this behavior opt-in with an env var, temporarily.
* feat(ui): UI :detach commandJustin M. Keyes2025-02-10
| | | | | | | | | | | Problem: Cannot detach the current UI. Solution: - Introduce `:detach`. - Introduce `Channel.detach`. Co-authored-by: bfredl <bjorn.linse@gmail.com>
* refactor: iwyu #31637Justin M. Keyes2024-12-23
| | | Result of `make iwyu` (after some "fixups").
* refactor(event): change last use of klist to kvecbfredl2024-09-28
| | | | | | | | | | | loop->children might have been a linked list because used to be modified in place while looped over. However the loops that exists rather schedules events to be processed later, outside of the loop, so this can not happen anymore. When a linked list is otherwise useful it is better to use lib/queue_defs.h which defines an _intrusive_ linked list (i e it doesn't need to do allocations for list items like klist ).
* refactor: rename "process" => "proc" #30387Justin M. Keyes2024-09-15
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.