mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* thread.c (rb_threadptr_execute_interrupts_common): check signal deliverly if it is main thread. fixes [ruby-dev:44005] [Ruby 1.9 - Bug #4950] * bootstraptest/test_fork.rb: add a test for above. * signal.c (rb_get_next_signal): skip if signal_buff is empty. (check signal_buff.size first) * vm_core.h: remove unused variable rb_thread_t::exec_signal. * thread.c (rb_thread_check_trap_pending): check rb_signal_buff_size() because rb_thread_t::exec_signal is no longer available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
		
			
				
	
	
		
			69 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			69 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
assert_equal '0', %q{
 | 
						|
  begin
 | 
						|
    GC.stress = true
 | 
						|
    pid = fork {}
 | 
						|
    Process.wait pid
 | 
						|
    $?.to_i
 | 
						|
  rescue NotImplementedError
 | 
						|
    0
 | 
						|
  end
 | 
						|
}, '[ruby-dev:32404]'
 | 
						|
 | 
						|
assert_finish 10, %q{
 | 
						|
  begin
 | 
						|
    children = (1..10).map{
 | 
						|
      Thread.start{fork{}}.value
 | 
						|
    }
 | 
						|
    while !children.empty? and pid = Process.wait
 | 
						|
      children.delete(pid)
 | 
						|
    end
 | 
						|
  rescue NotImplementedError
 | 
						|
  end
 | 
						|
}, '[ruby-core:22158]'
 | 
						|
 | 
						|
assert_normal_exit(<<'End', '[ruby-dev:37934]')
 | 
						|
  Thread.new { sleep 1; Thread.kill Thread.main }
 | 
						|
  Process.setrlimit(:NPROC, 1)
 | 
						|
  fork {}
 | 
						|
End
 | 
						|
 | 
						|
assert_equal 'ok', %q{
 | 
						|
  begin
 | 
						|
    if pid1 = fork
 | 
						|
      sleep 1
 | 
						|
      Process.kill("USR1", pid1)
 | 
						|
      _, s = Process.wait2(pid1)
 | 
						|
      s.success? ? :ok : :ng
 | 
						|
    else
 | 
						|
      if pid2 = fork
 | 
						|
        trap("USR1") { Time.now.to_s }
 | 
						|
        Process.wait2(pid2)
 | 
						|
      else
 | 
						|
        sleep 2
 | 
						|
      end
 | 
						|
      exit 0
 | 
						|
    end
 | 
						|
  rescue NotImplementedError
 | 
						|
    :ok
 | 
						|
  end
 | 
						|
}, '[ruby-core:28924]'
 | 
						|
 | 
						|
assert_equal '[1, 2]', %q{
 | 
						|
  a = []
 | 
						|
  trap(:INT) { a.push(1) }
 | 
						|
  trap(:TERM) { a.push(2) }
 | 
						|
  pid = $$
 | 
						|
  begin
 | 
						|
    fork do
 | 
						|
      sleep 0.5
 | 
						|
      Process.kill(:INT, pid)
 | 
						|
      Process.kill(:TERM, pid)
 | 
						|
    end
 | 
						|
 | 
						|
    sleep 1
 | 
						|
    a.sort
 | 
						|
  rescue NotImplementedError
 | 
						|
    [1, 2]
 | 
						|
  end
 | 
						|
}, '[ruby-dev:44005] [Ruby 1.9 - Bug #4950]'
 | 
						|
 |