]> git.feebdaed.xyz Git - 0xmirror/vim.git/commit
patch 9.1.2025: conpty terminal process may not start
authorMuraoka Taro <koron.kaoriya@gmail.com>
Sat, 27 Dec 2025 14:36:31 +0000 (14:36 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 27 Dec 2025 14:36:31 +0000 (14:36 +0000)
commit9f5b09ea1f37c9555bea1d950916bc94d271f68c
tree69ca5feb98a50a3cebea295f53d78fd4a745e454
parent4d5b30372663e8ea356b25fe94334558c6ae283f
patch 9.1.2025: conpty terminal process may not start

Problem:  Conpty terminal process may not start.
Solution: Do not close the input handle at EOF when conpty is in use.
          (Muraoka Taro)

It causes the following tests to fail in Windows conpty:

          - Test_terminal_duplicate_eof_arg()
          - Test_terminal_eof_arg()
          - Test_terminal_eof_arg_win32_ctrl_z()

To be precise, the process is launched, but immediately after it is
launched, the input handle to the console is closed with the EOF of the
input, and the console is terminated. When the console is terminated,
the associated process is also terminated.

In the Windows pseudo console, input and output handles are closed after
the process in the console has terminated.  This is not explicitly
stated in Microsoft's documentation.  However, looking at the code for
Windows Terminal, which is presented as a complete example of the pseudo
console, it is implemented exactly this way.

See the sample codes below:

- https://github.com/microsoft/terminal/blob/main/samples/ConPTY/EchoCon/EchoCon/EchoCon.cpp
- https://github.com/microsoft/terminal/blob/main/samples/ConPTY/GUIConsole/GUIConsole.ConPTY/Terminal.cs
- https://github.com/microsoft/terminal/blob/main/samples/ConPTY/MiniTerm/MiniTerm/Terminal.cs

The handle that is not closed at EOF is closed when Vim detects the end
of the job, so there is no risk of them being forgotten and leaking.

`ch_anonymous_pipe`, which was used to determine whether a channel was
for conpty, was set to TRUE only when conpty was being used. The
definition also had the comment `// ConPTY` attached to it.  This name
is not very appropriate, but I felt it would be rude to add a new field
to `channel_T` just for this purpose, so I reused it.

closes: #19025

Signed-off-by: Muraoka Taro <koron.kaoriya@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/channel.c
src/terminal.c
src/version.c