@@ -878,6 +878,45 @@ def test_stdio_gvar_reassignment_in_box_seen_by_kernel_methods
878878 end;
879879 end
880880
881+ def test_child_status_gvar_not_cached_in_box
882+ assert_separately ( [ ENV_ENABLE_BOX ] , __FILE__ , __LINE__ , "#{ <<~"begin;" } \n #{ <<~'end;' } " , ignore_stderr : true )
883+ begin;
884+ system(EnvUtil.rubybin, "-e", "exit 3")
885+ assert_equal 3, $?.exitstatus
886+ assert_equal Process.last_status.pid, $?.pid
887+ IO.popen([EnvUtil.rubybin, "-e", "exit 5"]) {|io| io.read}
888+ assert_equal 5, $?.exitstatus
889+ end;
890+ end
891+
892+ def test_child_status_gvar_not_cached_in_user_box
893+ assert_separately ( [ ENV_ENABLE_BOX ] , __FILE__ , __LINE__ , "#{ <<~"begin;" } \n #{ <<~'end;' } " , ignore_stderr : true )
894+ begin;
895+ ruby = EnvUtil.rubybin.dump
896+ first, second = Ruby::Box.new.eval(<<~CODE)
897+ system(#{ruby}, "-e", "exit 3")
898+ first = $?.exitstatus
899+ system(#{ruby}, "-e", "exit 5")
900+ [first, $?.exitstatus]
901+ CODE
902+ assert_equal 3, first
903+ assert_equal 5, second
904+ end;
905+ end
906+
907+ def test_pid_gvar_not_cached_in_forked_child
908+ omit "fork is not supported" unless Process . respond_to? ( :fork )
909+ assert_separately ( [ ENV_ENABLE_BOX ] , __FILE__ , __LINE__ , "#{ <<~"begin;" } \n #{ <<~'end;' } " , ignore_stderr : true )
910+ begin;
911+ _parent_pid = $$
912+ r, w = IO.pipe
913+ pid = fork { r.close; w.puts($$ == Process.pid); exit!(true) }
914+ w.close
915+ Process.wait(pid)
916+ assert_equal "true", r.read.chomp
917+ end;
918+ end
919+
881920 def test_errinfo_isolated_between_boxes
882921 assert_separately ( [ ENV_ENABLE_BOX ] , __FILE__ , __LINE__ , "#{ <<~"begin;" } \n #{ <<~'end;' } " , ignore_stderr : true )
883922 begin;
0 commit comments