discourse/script/check_forking.rb
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00

34 lines
593 B
Ruby

# frozen_string_literal: true
require File.expand_path("../../config/environment", __FILE__)
def pretty
puts "<before>"
puts PrettyText.cook("My pid is #{Process.pid}")
GC.start
sleep 1
puts "done gc"
end
Discourse.after_fork
pretty
child = fork do
Discourse.after_fork
pretty
grand_child = fork do
Discourse.after_fork
pretty
puts "try to exit"
Process.kill "KILL", Process.pid
end
puts "before wait 2"
Process.wait grand_child
puts "after wait 2"
Process.kill "KILL", Process.pid
end
puts "before wait 1"
Process.wait child
puts "after wait 1"