From 3b781c9370c34904facfcdd9c2e4c90f719a4875 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 5 Dec 2026 08:10:44 -0600 Subject: [PATCH 1/2] Tests(fix): Check Async control spawn cleanup why: The spawn failure test compared process-wide descriptor counts. Unrelated descriptors could close during the failed call. what: List the fixture session before moving the executable. Compare pipe identities around each failed control call, then restore the executable and exercise a connection in the same scope. --- test/integration/async_test.rb | 42 ++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/test/integration/async_test.rb b/test/integration/async_test.rb index 239a58f..087800d 100644 --- a/test/integration/async_test.rb +++ b/test/integration/async_test.rb @@ -744,35 +744,37 @@ def test_async_observer_failure_retains_and_reaps_its_real_child end def test_control_spawn_failure_is_reported_without_losing_admission - with_scope(control: true) do |scope, parent, fixture| + with_scope(control: true) do |_scope, parent, fixture| executable = File.join(File.dirname(fixture.socket_path), "removed-async-client") File.write(executable, "#!#{RbConfig.ruby} --disable=rubyopt,gems\nexec #{fixture.executable.inspect}, *ARGV\n") File.chmod(0o700, executable) LibTmux::Server.open(socket_path: fixture.socket_path, executable: executable) do |source| - ref = source.__send__(:build_entity, :session, "$0").ref - File.unlink(executable) + ref = source.list_sessions.first.ref + saved_executable = "#{executable}.saved" + File.rename(executable, saved_executable) LibTmux::Async.open(parent: parent, server: source, max_controls: 1) do |isolated| - before = Dir.children("/dev/fd").length - resources = lambda do - Dir.children("/dev/fd").filter_map do |fd| - target = File.readlink("/dev/fd/#{fd}") rescue nil - [fd, target] if target&.match?(/\A(?:pipe|socket|anon_inode):/) + pipes = lambda do + Dir.children("/dev/fd").filter_map do |descriptor| + stat = File.stat("/dev/fd/#{descriptor}") + [descriptor, stat.dev, stat.ino] if stat.pipe? + rescue Errno::ENOENT, Errno::EBADF + nil end end - before_resources = resources.call - trace = TracePoint.new(:call) do |event| - if event.method_id == :spawn && event.self.class.name.end_with?("::ControlDriver") - ::Async::Task.current.yield - end + 2.times do + before = pipes.call + failure = assert_raises(LibTmux::TransportError) { isolated.server.open_control(session: ref) } + assert_equal :spawn, failure.phase + assert_equal :not_sent, failure.delivery + assert_nil failure.pid + refute_includes failure.message, executable + assert_empty pipes.call - before, "failed control startup left new pipes open" end - trace.enable do - 2.times do - failure = assert_raises(LibTmux::TransportError) { isolated.server.open_control(session: ref) } - assert_equal :not_sent, failure.delivery - refute_includes failure.message, executable - end + + File.rename(saved_executable, executable) + isolated.server.open_control(session: ref) do |control| + assert_equal "recovered\n", control.exchange("display-message -p recovered").blocks.last.body end - assert_equal before, Dir.children("/dev/fd").length, (resources.call - before_resources).inspect end end end From 73e005e99f7fe3aaa61f0dbd427eddbfb2f4250b Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 5 Dec 2026 08:20:29 -0600 Subject: [PATCH 2/2] CI(docs): Note the Async control cleanup check why: Contributors need to know which behavior the Linux release check verifies. what: The Linux Async check detects pipes left open after a failed control launch and verifies the same scope can open another connection. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f00f95..3a1152a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,6 +93,8 @@ at one version, so a release has a section in each changelog. its own tmux server, and the root README shows `Server#explain_panes`, `Server#run_group` and `Server#open_control`. `Server#explain_panes` has an API example, which the docs site shows on its page. +- The Linux Async check detects pipes left open after a failed control launch + and verifies the same scope can open another connection. (#196) - Timed-out or interrupted release checks clean up their child processes and report the original failure without a reader-thread backtrace. (#176) - Ruby programs on the recipes page can be copied into an empty directory and