Skip to content

Commit 0646047

Browse files
h-eastmattn
authored andcommitted
runtime(doc): clarify term_start() I/O behavior for Unix pty and MS-Windows ConPTY
Explain how stdin/stdout/stderr are connected in term_start(): - On Unix, they default to pty; only "err_cb" switches stderr to a pipe, which may cause output order differences due to buffering. - On MS-Windows with ConPTY, they are always pipes and stdout/stderr share the same pipe, so "err_cb" cannot separate them. related: #16354 Co-authored-by: Yasuhiro Matsumoto <[email protected]> Signed-off-by: Hirohito Higashi <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent b2ff915 commit 0646047

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

runtime/doc/terminal.txt

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*terminal.txt* For Vim version 9.2. Last change: 2026 Mar 12
1+
*terminal.txt* For Vim version 9.2. Last change: 2026 Apr 02
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -944,9 +944,26 @@ term_start({cmd} [, {options}]) *term_start()*
944944
"in_io", "in_top", "in_bot", "in_name", "in_buf"
945945
"out_io", "out_name", "out_buf", "out_modifiable", "out_msg"
946946
"err_io", "err_name", "err_buf", "err_modifiable", "err_msg"
947-
However, at least one of stdin, stdout or stderr must be
948-
connected to the terminal. When I/O is connected to the
949-
terminal then the callback function for that part is not used.
947+
On Unix:
948+
stdin, stdout, and stderr are connected to a pty by default,
949+
since bidirectional communication with the terminal is
950+
required. Setting "out_cb" does not switch stdout from the
951+
pty to a pipe. Only setting "err_cb" switches stderr to a
952+
pipe.
953+
Note: Since a pty is line-buffered and a pipe is
954+
block-buffered, the order of output between stdout and stderr
955+
may not be preserved. Without "err_cb", stderr uses the same
956+
pty as stdout, so the output order is preserved but stdout and
957+
stderr cannot be distinguished.
958+
959+
On MS-Windows with |ConPTY|:
960+
stdin, stdout, and stderr are always connected through pipes
961+
to the pseudo console, regardless of callback settings.
962+
Since stdout and stderr share the same pipe, they cannot be
963+
separated by "err_cb".
964+
This is because the CreatePseudoConsole() API only accepts one
965+
input and one output handle, with no separate handle for
966+
stderr.
950967

951968
There are extra options:
952969
"term_name" name to use for the buffer name, instead

0 commit comments

Comments
 (0)