<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/test/ruby/test_sleep.rb, branch v4.0.3</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>merge revision(s) 7e81bf5c0c8f43602e6d901f4253dca2f3d71745: [Backport #21812]</title>
<updated>2026-01-13T01:14:52+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2026-01-13T01:14:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ac596948d4008c6e117449786c62de4e45e434bf'/>
<id>ac596948d4008c6e117449786c62de4e45e434bf</id>
<content type='text'>
	[PATCH] Fix sleep spurious wakeup from sigchld (#15802)

	When sleeping with `sleep`, currently the main thread can get woken up from sigchld
	from any thread (subprocess exited). The timer thread wakes up the main thread when this
	happens, as it checks for signals. The main thread then executes the ruby sigchld handler
	if one is registered and is supposed to go back to sleep immediately. This is not ideal but
	it's the way it's worked for a while. In commit 8d8159e7d8 I added writes to `th-&gt;status`
	before and after `wait_running_turn` in `thread_sched_to_waiting_until_wakeup`, which is
	called from `sleep`. This is usually the right way to set the thread's status, but `sleep`
	is an exception because the writes to `th-&gt;status` are done in `sleep_forever`. There's a
	loop that checks `th-&gt;status` in `sleep_forever`. When the main thread got woken up from
	sigchld it saw the changed `th-&gt;status` and continued to run the main thread instead of
	going back to sleep.

	The following script shows the error. It was returning instead of sleeping forever.

	```ruby
	t = 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}"
	```

	Fixes [Bug #21812]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[PATCH] Fix sleep spurious wakeup from sigchld (#15802)

	When sleeping with `sleep`, currently the main thread can get woken up from sigchld
	from any thread (subprocess exited). The timer thread wakes up the main thread when this
	happens, as it checks for signals. The main thread then executes the ruby sigchld handler
	if one is registered and is supposed to go back to sleep immediately. This is not ideal but
	it's the way it's worked for a while. In commit 8d8159e7d8 I added writes to `th-&gt;status`
	before and after `wait_running_turn` in `thread_sched_to_waiting_until_wakeup`, which is
	called from `sleep`. This is usually the right way to set the thread's status, but `sleep`
	is an exception because the writes to `th-&gt;status` are done in `sleep_forever`. There's a
	loop that checks `th-&gt;status` in `sleep_forever`. When the main thread got woken up from
	sigchld it saw the changed `th-&gt;status` and continued to run the main thread instead of
	going back to sleep.

	The following script shows the error. It was returning instead of sleeping forever.

	```ruby
	t = 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}"
	```

	Fixes [Bug #21812]
</pre>
</div>
</content>
</entry>
<entry>
<title>Replace all GC.disable with EnvUtil.without_gc</title>
<updated>2024-09-17T14:34:26+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-09-16T19:29:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=0160dafc4c52b84bb1f989670b54186505649493'/>
<id>0160dafc4c52b84bb1f989670b54186505649493</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add frozen_string_literal: false for all files</title>
<updated>2015-12-16T05:07:31+00:00</updated>
<author>
<name>naruse</name>
<email>naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2015-12-16T05:07:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=3e92b635fb5422207b7bbdc924e292e51e21f040'/>
<id>3e92b635fb5422207b7bbdc924e292e51e21f040</id>
<content type='text'>
When you change this to true, you may need to add more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When you change this to true, you may need to add more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>I suspect such early wakeup is because of automatic time correction</title>
<updated>2014-05-22T10:42:06+00:00</updated>
<author>
<name>naruse</name>
<email>naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2014-05-22T10:42:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4c9ec80ece69b0295f88dcc4262960bc0c298b2a'/>
<id>4c9ec80ece69b0295f88dcc4262960bc0c298b2a</id>
<content type='text'>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>Use Etc.uname instead of uname command invocation.</title>
<updated>2014-05-18T08:45:37+00:00</updated>
<author>
<name>akr</name>
<email>akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2014-05-18T08:45:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=bd4fdb714ff6cf3d42d5a7e6597e83cbe4de65b8'/>
<id>bd4fdb714ff6cf3d42d5a7e6597e83cbe4de65b8</id>
<content type='text'>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>call to_i</title>
<updated>2014-04-24T01:01:18+00:00</updated>
<author>
<name>naruse</name>
<email>naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2014-04-24T01:01:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=8c3b01022b932e57800419abb5ed0056e8120399'/>
<id>8c3b01022b932e57800419abb5ed0056e8120399</id>
<content type='text'>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>test_sleep.rb: get rid of failure on Windows</title>
<updated>2013-10-06T00:22:58+00:00</updated>
<author>
<name>nobu</name>
<email>nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2013-10-06T00:22:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=803c3929b8e2d77ba4c7f5678eef563d5aa77c09'/>
<id>803c3929b8e2d77ba4c7f5678eef563d5aa77c09</id>
<content type='text'>
* test/ruby/test_sleep.rb (test_sleep_5sec): relax bottom on Windows.
  assert_operator should test on the receiver.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* test/ruby/test_sleep.rb (test_sleep_5sec): relax bottom on Windows.
  assert_operator should test on the receiver.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>Cent OS 5.6 wakes up in 4.989596sec from sleep(5).</title>
<updated>2012-04-24T12:17:02+00:00</updated>
<author>
<name>naruse</name>
<email>naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2012-04-24T12:17:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=276d82a7c8cf8f5e80c057f3b85dc293eb573fd7'/>
<id>276d82a7c8cf8f5e80c057f3b85dc293eb573fd7</id>
<content type='text'>
http://c5632.rubyci.org/~chkbuild/ruby-trunk/log/20120424T070102Z.log.html.gz

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
http://c5632.rubyci.org/~chkbuild/ruby-trunk/log/20120424T070102Z.log.html.gz

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix typo.</title>
<updated>2012-03-06T09:47:17+00:00</updated>
<author>
<name>naruse</name>
<email>naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2012-03-06T09:47:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=2fbc01fb56332d5a611984570ff7346acd844eeb'/>
<id>2fbc01fb56332d5a611984570ff7346acd844eeb</id>
<content type='text'>
reported by Nobuhiro IMAI.$
https://twitter.com/no6v/status/176959588531314688

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
reported by Nobuhiro IMAI.$
https://twitter.com/no6v/status/176959588531314688

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
<entry>
<title>* test/ruby/test_sleep.rb (TestSleep#test_sleep_5sec): syntax error.</title>
<updated>2012-03-05T07:51:31+00:00</updated>
<author>
<name>usa</name>
<email>usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e</email>
</author>
<published>2012-03-05T07:51:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=842c6f605bdd87bc931b1426bd9f1ea3ca1ba3dd'/>
<id>842c6f605bdd87bc931b1426bd9f1ea3ca1ba3dd</id>
<content type='text'>
* test/ruby/test_sleep.rb (TestSleep#test_sleep_5sec): call uname
  only on linux because it's a workaround for linux only.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* test/ruby/test_sleep.rb (TestSleep#test_sleep_5sec): call uname
  only on linux because it's a workaround for linux only.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
</pre>
</div>
</content>
</entry>
</feed>
