Could you try this version:
<---
a = []
trap(:INT) { puts "INT recvd" ; a.push(1) }
trap(:TERM) { puts "TERM recvd" ; a.push(2) }
pid = $$
puts "parent pid: #{pid}"
begin
 fork do
   puts "child pid: #{$$}"
   sleep 0.5
   Process.kill(:INT, pid)
   Process.kill(:TERM, pid)
   puts "signals sent."
 end
 sleep 1
 a.sort
 p a
rescue NotImplementedError
 [1, 2]
end
---->

parent pid: 44147
child pid: 44150
signals sent.
[]

According to ktrace, signals are sent to parent pid.
It might be related to our pid semantic, each thread have different pid.
The signal cannot be received by a different thread.



#934 test_thread.rb:389:in `<top (required)>':
     open("zzz.rb", "w") do |f|
       f.puts <<-END
         begin
           m = Mutex.new
           Thread.new { m.lock; sleep 1 }
           sleep 0.3
           parent = Thread.current
           Thread.new do
             sleep 0.3
             begin
               fork { GC.start }
             rescue Exception
               parent.raise $!
             end
           end
           m.lock
           pid, status = Process.wait2
           $result = status.success? ? :ok : :ng
         rescue NotImplementedError
           $result = :ok
         end
       END
     end
     require "./zzz.rb"
     $result
  #=> "" (expected "ok")
FAIL 2/937 tests failed
make: *** [yes-btest-ruby] Error 1

Very strange. What about this script?

May be not.

For what should "Process.wait2" wait ?

The fork of garbage collector and wait2 seems be by a different thread,
which with our pthread implementration does not work.

<------
m = Mutex.new
Thread.new { m.lock; sleep 3 ;  puts "after m.lock in thread" }
sleep 1
m.lock
puts "after m.lock"
------>

after m.lock in thread
after m.lock





--
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to