[ruby-core:124383] [Ruby Bug#21812] Kernel#sleep without arguments returns immediately when subprocess exits in another thread (regression in Ruby 4.0)
Issue #21812 has been reported by jaimevelaz (Jaime Velaz). ---------------------------------------- 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 * Author: jaimevelaz (Jaime Velaz) * Status: Open * 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/
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/
Issue #21812 has been updated by k0kubun (Takashi Kokubun). Backport changed from 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONTNEED, 4.0: REQUIRED to 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONTNEED, 4.0: DONE ruby_4_0 commit:ac596948d4008c6e117449786c62de4e45e434bf merged revision(s) commit:7e81bf5c0c8f43602e6d901f4253dca2f3d71745. ---------------------------------------- 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-116045 * Author: jaimevelaz (Jaime Velaz) * Status: Closed * Assignee: luke-gru (Luke Gruber) * ruby -v: ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [arm64-darwin25] * Backport: 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONTNEED, 4.0: DONE ---------------------------------------- **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/
participants (3)
-
jaimevelaz (Jaime Velaz) -
k0kubun (Takashi Kokubun) -
mame (Yusuke Endoh)