aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/pty_process_unix.c
Commit message (Collapse)AuthorAge
* refactor(pty): remove old logic for inheriting termios from host terminalbfredl2023-01-10
|
* fix(embed): handle stdio in server properlybfredl2023-01-09
| | | | | Rename stdin/stdout in the server, so that RPC data won't get corrupted. This also restores the use of stderr to write directly to the terminal.
* build: allow IWYU to fix includes for all .c filesdundargoc2022-11-15
| | | | | | | | | | Allow Include What You Use to remove unnecessary includes and only include what is necessary. This helps with reducing compilation times and makes it easier to visualise which dependencies are actually required. Work on https://github.com/neovim/neovim/issues/549, but doesn't close it since this only works fully for .c files and not headers.
* refactor: move klib out of src/nvim/ #20341dundargoc2022-09-25
| | | | It's confusing to mix vendored dependencies with neovim source code. A clean separation is simpler to keep track of and simpler to document.
* feat(logging): include test-id in log messagesJustin M. Keyes2022-06-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: 1. Log messages (especially in CI) are hard to correlate with tests. 2. Since b353a5c05f02 #11886, dumplog() prints the logs next to test failures. This is noisy and gets in the way of the test results. Solution: 1. Associate an incrementing id with each test and include it in log messages. - FUTURE: add v:name so Nvim instances can be formally "named"? 2. Mention "child" in log messages if the current Nvim is a child (based on the presence of $NVIM). BEFORE: DBG … 12345 UI: event DBG … 12345 log_server_msg:722: RPC ->ch 1: … DBG … 12345 UI: flush DBG … 12345 inbuf_poll:444: blocking... events_enabled=1 events_pending=0 DBG … 23454 UI: stop INF … 23454 os_exit:594: Nvim exit: 0 AFTER: DBG … T57 UI: event DBG … T57 log_server_msg:722: RPC ->ch 1: … DBG … T57 UI: flush DBG … T57 inbuf_poll:444: blocking... events_enabled=1 events_pending=0 DBG … T57/child UI: stop INF … T57/child os_exit:594: Nvim exit: 0
* chore: fix typos (#17670)dundargoc2022-03-17
| | | Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* refactor(uncrustify): format all c filesDundar Göc2022-03-10
|
* fix: add forkpty for SunOS variantsClaes Nästén2021-12-12
| | | | | forkpty is missing on Solaris < 11 and Illumos, provide fallback implementation for non Solaris 11 users.
* fix: don't use cfsetspeed, use i and o variantsClaes Nästén2021-12-07
| | | | | cfsetspeed is not available on SunOS, use cfsetispeed and cfsetospeed instead.
* fix: don't include pty.h on SunOSClaes Nästén2021-12-07
|
* Refactor/uncrustify (#15790)dundargoc2021-09-29
| | | | | | | | | | | | | * refactor: format with uncrustify * fixup(dundar): fix functions comments * fixup(dundar): remove space between variable and ++/-- * fixup(dundar): better workaround for macro attributes This is done to be able to better use uncrustify rules for macros * fixup(justin): make preprocessors follow neovim style guide
* refactor: format files with uncrustify #15663dundargoc2021-09-14
|
* Add more info to debug messagesJames McCoy2021-04-08
| | | | [skip ci]
* fix(pty): Always use $TERM from the job's env dictJames McCoy2021-02-06
| | | | | | | | | | | | | | | | | | | | | | Before #12937, the only way to specify the `$TERM` for a pty job was through the `TERM` key in the job's opts dict. This was shuttled to the child process throug a special field on the PtyProcess object and injected into the environment after forking. Now that we have a proper way to specify the environment for a job, we can simply ensure that the env dict has a proper `TERM` set and avoid the extra shuttling of data around. This deprecates the use of the `TERM` option, but will still honor it if present, although at a lower priority than a `TERM` present in the env dict. This also fixes #13874 because we're no longer trying to overwrite `TERM` in the env dict with the special pty `term_name`. Doing so raises an internal error because of the existing key which, under certain circumstances, would cause the "hit enter" prompt. However, since the child process had already forked, there was no way for the user to acknowledge the prompt and we would just hang there.
* fix(pty_proc/macOS): Properly set the environment for the childJames McCoy2021-01-31
| | | | | | Binding _NSGetEnviron()'s return value to a local variable and then re-binding that is incorrect. We need to directly update what _NSGetEnviron() refers to.
* Common handling of required/ignored env varsJames McCoy2021-01-31
| | | | | | | | | | When starting a pty job, there are certain env vars that we need to either add or remove. Currently, there are two relevant scenarios. * Removing irrelevant env vars on Unix, mostly related to the terminal hosting nvim since they do not apply to a libvterm-hosted terminal. * Adding required env vars for Windows jobs.
* Use dict_T to pass env vars to process spawning codeJames McCoy2021-01-31
| | | | Co-authored-by: Matthieu Coudron <mattator@gmail.com>
* Fix colors in terminal by maintaining COLORTERMThomas Fehér2020-11-26
| | | | Fixes https://github.com/neovim/neovim/issues/10836
* channels: reflect exit due to signals in exit status code (#10573)Daniel Hahler2019-08-09
| | | | | Uses `128 + term_signal` in case of exit due to a signal. Fixes https://github.com/neovim/neovim/issues/10571.
* CI: improve gcov handling #10404Daniel Hahler2019-07-07
| | | | | | | | | - Move __gcov_flush to process_spawn, for more reliable coverage tracking of subprocesses - Travis: use GCOV_ERROR_FILE - codecov: use "-X fix" to skip "fixing" uploaded coverage data; it should be handled by codecov's backend instead. - AppVeyor: no $PATH mangling, which breaks with the improved coverage tracking due to missing .dll in PATH.
* gcov: use __gcov_flush instead of __gcov_dump (#10260)Daniel Hahler2019-06-18
| | | | | | This restores missing coverage again. Move it to process_spawn in os/pty_process_unix.c, since it seems to break printargs-test on Windows/AppVeyor otherwise (#10248).
* clint: check env functionsJustin M. Keyes2019-02-28
|
* os/env: use libuv v1.12 getenv/setenv APIJustin M. Keyes2019-02-27
| | | | | | | | | | | - Minimum required libuv is now v1.12 - Because `uv_os_getenv` requires allocating, we must manage a map (`envmap` in `env.c`) to maintain the old behavior of `os_getenv` . - free() map-items after removal. khash.h does not make copies of anything, so even its keys must be memory-managed by the caller. closes #8398 closes #9267
* TUI: detect BSD vt consoleJustin M. Keyes2018-12-16
| | | | | | | | | | | | | | FreeBSD console sets TERM=xterm, but it does not support xterm features like cursor-shaping. GUI terminals typically set TERM=xterm-256color, so on FreeBSD we can guess that TERM=xterm is the degraded vt. OpenBSD console sets TERM=vt220 https://github.com/openbsd/src/blob/master/etc/etc.amd64/ttys NetBSD console sets TERM=vt100 https://github.com/NetBSD/src/blob/trunk/etc/etc.amd64/ttys closes #8644
* Check all child processes for exit in SIGCHLD handlerDavid Hotham2018-07-14
| | | | | | | | If a second and third child exit while we are already in the handler, we will only see a single additional SIGCHLD. Therefore the handler must not stop after processing a single child but should check all children. Fixes #8740
* Only waitpid() for processes that we care aboutDavid Hotham2018-07-13
| | | | | | | | | | | | | | | | | | | | | | It seems as though in an AppImage there's an extra child process that dies at some early point, before we have set up a SIGCHLD handler. So when we later get a SIGCHLD from a child that we do care about, waitpid(-1, ...) tells us about the extra child - and we don't notice that the interesting child has exited. Or something like that! See also: * https://patchwork.kernel.org/patch/9949491/ in which perf hit something similar * discussion at the AppImage repository: https://github.com/AppImage/AppImageKit/issues/812#issuecomment-404662110. Fix is to be explicit about which process we are waitpid()'ing for, so we never need be distracted by children that we don't know about. Fixes #8104
* doc: job/channel, misc #7783Justin M. Keyes2018-06-11
| | | | | | | | | | | doc: termios defaults. ref #6992 doc: :help shell-powershell doc: provider: Python minimum version is 2.7, 3.4 doc: remove :!start special-case. #5844 doc: mention #7917 change which accepts empty Array for Dictionary parameter doc: <Cmd> pseudokey doc: lmap change #5658 doc: -s, -es
* api: list information about all channels/jobs.Björn Linse2018-05-23
| | | | | Fire autocmd when channel opens or its info changes. Add a way for API clients can describe themselves.
* jobs: child proc must have a separate process-groupJustin M. Keyes2018-03-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | UV_PROCESS_DETACHED compels libuv:uv__process_child_init() to call setsid() in the child just after fork(). That ensures the process and its descendants are grouped in a separate session (and process group). The following jobstart() call correctly groups `sh` and `sleep` in a new session (and process-group), where `sh` is the "session leader" (and process-group leader): :call jobstart(['sh','-c','sleep 60']) SESN PGRP PID PPID Command 30383 30383 30383 3620 │ ├─ -bash 30383 31432 31432 30383 │ │ └─ nvim -u NORC 30383 31432 31433 30383 │ │ ├─ nvim -u NORC 8105 8105 8105 31432 │ │ └─ sh -c sleep 60 8105 8105 8106 8105 │ │ └─ sleep 60 closes #6530 ref: https://stackoverflow.com/q/1046933 ref: https://unix.stackexchange.com/a/404065 Helped-by: Marco Hinz <mh.codebro+github@gmail.com> Discussion ------------------------------------------------------------------------ On my linux box before this patch, the termclose_spec.lua:'kills job trapping SIGTERM' test indirectly causes cmake/busted to wait for 60s. That's because the test spawns a `sleep 60` descendant process which hangs around even after nvim exits: nvim killed the parent PID, but not PGID (process-group), so the grandchild "reparented" to init (PID 1). Session contains processes (and process-groups) which are logically part of the same "login session". Process-group is a set of logically/informally-related processes within a session; for example, shells assign a process group to each "job". Session IDs and PGIDs both have type pid_t (like PIDs). These OS-level mechanisms are, as usual, legacy accidents whose purpose is upheld by convention and folklore. We can use session-level grouping (setsid), or we could use process-group-level grouping (setpgid). Vim uses setsid() if available, otherwise setpgid(0,0). Windows ------------------------------------------------------------------------ UV_PROCESS_DETACHED on win32 sets CREATE_NEW_PROCESS_GROUP flag. But uv_kill() does not kill the process-group: https://github.com/nodejs/node/issues/3617 Ideas: - Set UV_PROCESS_DETACHED (CREATE_NEW_PROCESS_GROUP), then call GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, pid) - Maybe won't work because MSDN says "Only processes that share the same console as the calling process receive the signal." https://docs.microsoft.com/en-us/windows/console/generateconsolectrlevent But CREATE_NEW_PROCESS_GROUP creates a new console ... ref https://stackoverflow.com/q/1453520 - Group processes within a "job". libuv does that *globally* for non-detached processes: uv__init_global_job_handle. - Iterate through CreateToolhelp32Snapshot(). - https://stackoverflow.com/q/1173342 - Vim does this, see terminate_all()
* pty_process_unix: _exit() on execvp() failureJustin M. Keyes2017-12-13
| | | | | Mostly cargo-culting based on a reading of the manpages, interwebs, and the Vim source.
* tui: job-control: use saved termios for pty jobsJustin M. Keyes2017-11-25
| | | | | | | | | | | | | | On startup, if running in a terminal, save the termios properties. Use the saved termios for `:terminal` and `jobstart()` pty jobs. This won't affect nvim spawned outside of a terminal. questions: - This affects `:terminal` and `jobstart({'pty':v:true})`. Should we be more conservative for `jobstart({'pty':v:true})` (e.g. pass NULL to forkpty() and let the OS defaults prevail)? - Note: `iutf8` would not be set in that case.
* channels: refactorBjörn Linse2017-11-24
|
* pty_process_unix.c: include <libutil.h> on DragonFly BSDJustin M. Keyes2017-05-21
| | | | | | | From FreeBSD ports patch: https://svnweb.freebsd.org/ports/head/editors/neovim/files/patch-src_nvim_os_pty__process__unix.c?revision=425833&view=markup References https://github.com/neovim/neovim/issues/6771#issuecomment-302921368
* *: Add comment to all C filesZyX2017-04-19
|
* job-control: set CLOEXEC on pty processes. #5986Matthew Malcomson2017-03-17
| | | | | Before this change, new processes started with libuv prevented SIGHUP from reaching pty processes (by keeping the ptmx file descriptor open).
* process_spawn: Return status code (#6075)Justin M. Keyes2017-02-09
|
* Remove redundant includes of unistd.h (#5126)Rui Abreu Ferreira2016-07-29
|
* eval: allow setting cwd in {jobstart,termopen}()Aleksa Sarai2016-06-07
| | | | | | | | | | | Processes in vim are always started in the current directory, which causes issues when the process is a daemon and the current directory is a mountpoint. Fix this by adding an option to set the cwd of the new process with jobstart(). In addition, fix termopen() so that it actually uses the cwd option from the dict (it couldn't previously set the cwd value due to dead code). Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
* pty_process: split into plat-specific files (#3976)Rui Abreu Ferreira2016-06-04