$ qemu-x86_64 --version
qemu-x86_64 version 9.0.50 (v9.0.0-1211-gd16cab541a)
Copyright (c) 2003-2024 Fabrice Bellard and the QEMU Project developers
$ cat fork.rb 
begin
  r, w = IO.pipe
  if pid1 = fork
    w.close
    r.read 1
    Process.kill "USR1", pid1
    Process.wait2 pid1
  else
    print "child\n"
    r.close
    if pid2 = fork
      trap("USR1") { print "child: kill\n"; Process.kill "USR2", pid2 }
      w.close
      print "child: wait\n"
      Process.wait2 pid2
    else
      print "grandchild\n"
      w.close
      sleep 0.2
    end
  end
end
$ ruby fork.rb
child
child: wait
grandchild
child: kill
$ qemu-x86_64 /usr/bin/ruby fork.rb
child
child: wait
^Z
[1]+  Stopped                 qemu-x86_64 /usr/bin/ruby fork.rb
$ grep SigB $(for p in $(pidof qemu-x86_64); do echo /proc/$p/status; done | 
sort)
/proc/3221/status:SigBlk:       0000000000000000
/proc/3224/status:SigBlk:       0000000000000000
/proc/3228/status:SigBlk:       fffffff27ffbfa9f

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

Reply via email to