simon-git: putty (main): Simon Tatham
Commits to Tartarus hosted VCS
tartarus-commits at lists.tartarus.org
Tue Apr 14 16:58:40 BST 2026
TL;DR:
ccd3d371 Centralise the call to execute_command_hook.
1bf88ffb New centralised system for waiting for subprocesses.
6aab75a4 HandleSocket: stop tying input and output EOF together.
a0659c2a Run pre-connect commands via platform_start_subprocess.
ff89d584 Refactor pty_real_select_result. (NFC)
7a7da336 Switch unix/pty.c to use the new SubprocessWaiter.
Repository: https://git.tartarus.org/simon/putty.git
On the web: https://git.tartarus.org/?p=simon/putty.git
Branch updated: main
Committer: Simon Tatham <anakin at pobox.com>
Date: 2026-04-14 16:58:40
commit ccd3d3715f3d6ec8eb89b9fbd20f743a00551269
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=ccd3d3715f3d6ec8eb89b9fbd20f743a00551269;hp=af996b5ec27ab79bae3882071b9d6acf16044549
Author: Simon Tatham <anakin at pobox.com>
Date: Mon Apr 13 13:02:47 2026 +0100
Centralise the call to execute_command_hook.
Now there's a function new_main_connection() in proxy/newmain.c, which
is called in place of new_connection() when the connection you're
making is the primary one of the session (as opposed to some sub-thing
like a port forwarding). So now running the pre-connect command is
done inside there.
This is more DRY in general, but more specifically, allows
new_main_connection() to be implemented in a more sophisticated way.
The new function differs in API from new_connection() in that it
requires a LogContext as well as all the other parameters.
CMakeLists.txt | 1 +
network.h | 7 +++++++
otherbackends/raw.c | 10 +++-------
otherbackends/rlogin.c | 11 +++--------
otherbackends/supdup.c | 11 +++--------
otherbackends/telnet.c | 11 +++--------
proxy/newmain.c | 15 +++++++++++++++
ssh/ssh.c | 11 +++--------
8 files changed, 38 insertions(+), 39 deletions(-)
commit 1bf88ffbe8ddd85f60e601c59a77950e23ac7e74
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=1bf88ffbe8ddd85f60e601c59a77950e23ac7e74;hp=ccd3d3715f3d6ec8eb89b9fbd20f743a00551269
Author: Simon Tatham <anakin at pobox.com>
Date: Tue Apr 14 09:50:43 2026 +0100
New centralised system for waiting for subprocesses.
There's a new 'SubprocessWaiter' object, which you can optionally ask
for as an extra result of platform_start_subprocess, and then tell it
how to give you a callback when the subprocess terminates.
Not yet used: the existing use of platform_start_subprocess only cared
about the output pipe of the subprocess anyway, so it passes NULL as
the extra output pointer, indicating that it doesn't need a waiter.
defs.h | 2 +
putty.h | 27 +++++--
ssh/userauth2-client.c | 2 +-
stubs/no-network.c | 10 ++-
unix/CMakeLists.txt | 1 +
unix/local-proxy.c | 20 +++--
unix/platform.h | 3 +
unix/utils/subprocess_waiter.c | 162 ++++++++++++++++++++++++++++++++++++++
windows/CMakeLists.txt | 1 +
windows/local-proxy.c | 23 ++++--
windows/platform.h | 3 +
windows/utils/subprocess_waiter.c | 73 +++++++++++++++++
12 files changed, 308 insertions(+), 19 deletions(-)
commit 6aab75a4ec760b3d8a2fa94260a4ebb6ca815b74
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=6aab75a4ec760b3d8a2fa94260a4ebb6ca815b74;hp=1bf88ffbe8ddd85f60e601c59a77950e23ac7e74
Author: Simon Tatham <anakin at pobox.com>
Date: Tue Apr 14 16:19:41 2026 +0100
HandleSocket: stop tying input and output EOF together.
If a HandleSocket is used with a pair of pipes, we can send outgoing
EOF by closing the output pipe, without necessarily closing the input
pipe. But we were unconditionally closing both anyway.
This makes no difference to usages involving named pipes; it only
makes a difference with local proxy subprocesses.
windows/handle-socket.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
commit a0659c2a614b64a05952701fdd96a7bf992efe4d
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=a0659c2a614b64a05952701fdd96a7bf992efe4d;hp=6aab75a4ec760b3d8a2fa94260a4ebb6ca815b74
Author: Simon Tatham <anakin at pobox.com>
Date: Mon Apr 13 14:02:44 2026 +0100
Run pre-connect commands via platform_start_subprocess.
This fixes the limitation of the previous execute_command_hook() that
it blocked the whole PuTTY process while waiting for the pre-connect
command to terminate. Now, if the subcommand unexpectedly takes a long
time, PuTTY itself will still be responsive â you can check its Event
Log to see what's going on, or close it if you realise the command is
never going to succeed, or simply copy-paste stuff from the terminal
window while you wait.
platform_start_subprocess opens three pipes to run the command in (on
both Unix and Windows), for stdin, stdout and stderr. Here, stdin is a
liability: we don't have any input to give the command, so if it were
to stop to try to read from stdin, it would blockk. Therefore we send
an outgoing EOF immediately by closoing the pipe to the command's
stdin, so that instead of blocking, it will immediately find out
there's no input for it.
doc/config.but | 6 -
proxy/newmain.c | 365 ++++++++++++++++++++++++++++++++++++++++++-
unix/CMakeLists.txt | 1 -
unix/utils/command_hook.c | 130 ---------------
windows/CMakeLists.txt | 1 -
windows/utils/command_hook.c | 140 -----------------
6 files changed, 359 insertions(+), 284 deletions(-)
commit ff89d584c55f281aca40609d65f18e25c9ef20fa
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=ff89d584c55f281aca40609d65f18e25c9ef20fa;hp=a0659c2a614b64a05952701fdd96a7bf992efe4d
Author: Simon Tatham <anakin at pobox.com>
Date: Tue Apr 14 10:29:53 2026 +0100
Refactor pty_real_select_result. (NFC)
pty_real_select_result was a monolithic function which included
handling the result of waitpid() (indicated by passing magic -1 values
as fd and event), or actually reading data from the pty (in the
absence of those special values), and cleanup functionality if either
of those things indicated that it was time to finish the session.
Now the magic values are gone: waitpid() results are handled in their
own function. Also the shared cleanup functionality lives in the new
pty_finished() routine, called from both that and the remainder of
pty_real_select_result(), which now just handles _actual_ results of
select() reporting activity on the pty fd.
This patch is completely boring: it just moves existing code around
and reindents it. The interesting change will come in the next commit;
this one just separates the boring parts of the work, to make the
interesting patch easier to read.
unix/pty.c | 255 +++++++++++++++++++++++++++++++------------------------------
1 file changed, 130 insertions(+), 125 deletions(-)
commit 7a7da3365a6d7b74382f96fde42509d7ae81cf1d
web diff https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=7a7da3365a6d7b74382f96fde42509d7ae81cf1d;hp=ff89d584c55f281aca40609d65f18e25c9ef20fa
Author: Simon Tatham <anakin at pobox.com>
Date: Tue Apr 14 10:34:09 2026 +0100
Switch unix/pty.c to use the new SubprocessWaiter.
The mechanisms in there - SIGCHLD handler, self-pipe with uxsel, wait
loop, tree of known subprocesses indexed by pid - are all replicated
in the new centralised system, so there's no need to have two copies
of them.
This also extends the Unix-specific API of SubprocessWaiter to add a
couple of extra 'forcibly do a thing you would have got round to
later' functions.
putty.h | 7 +-
unix/platform.h | 5 ++
unix/pty.c | 185 ++++++++++-------------------------------
unix/utils/subprocess_waiter.c | 13 +--
4 files changed, 61 insertions(+), 149 deletions(-)
More information about the tartarus-commits
mailing list