Issue #21812 has been updated by mame (Yusuke Endoh). Status changed from Open to Assigned Assignee set to luke-gru (Luke Gruber) Thanks for the nice catch. `git bisect` points to commit:8d8159e7d87e4fd1594ce2fad3d2653e47fb1026. The changes in that commit seem relevant to this issue. @luke-gru Could you take a look? ---------------------------------------- Bug #21812: Kernel#sleep without arguments returns immediately when subprocess exits in another thread (regression in Ruby 4.0) https://bugs.ruby-lang.org/issues/21812#change-115893 * Author: jaimevelaz (Jaime Velaz) * Status: Assigned * Assignee: luke-gru (Luke Gruber) * ruby -v: ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [arm64-darwin25] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- **Description** In Ruby 4.0.0, Kernel#sleep without arguments returns 0 immediately when a subprocess (spawned via backticks in another thread) exits. This is a regression from Ruby 3.4.8 where sleep blocks indefinitely as expected. Note: sleep(N) with an argument is not affected. --- **Steps to reproduce** ``` # test_sleep.rb Thread.new do sleep 0.3 `echo hello` # Spawns subprocess puts "Subprocess exited" end puts "Main thread sleeping..." result = sleep # Should block forever puts "sleep returned: #{result.inspect}" ``` Run with: `$ ruby test_sleep.rb` --- Actual result (Ruby 4.0.0): Main thread sleeping... Subprocess exited sleep returned: 0 The program exits immediately after the subprocess completes. --- Expected result (Ruby 3.4.8 behavior): Main thread sleeping... Subprocess exited (process blocks indefinitely until interrupted by signal) The program should block forever until explicitly interrupted by SIGINT/SIGTERM. -- https://bugs.ruby-lang.org/