Skip to content

Commit ef306fb

Browse files
authored
Fix: reinit event loop first after fork (UNIX) (#14975)
Signal handling manipulate pipes (file descriptors) on UNIX, and messing with the evloop after fork can affect the parent process evloop in some cases.
1 parent cf15fb2 commit ef306fb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/kernel.cr

+5-5
Original file line numberDiff line numberDiff line change
@@ -584,14 +584,14 @@ end
584584
# Hooks are defined here due to load order problems.
585585
def self.after_fork_child_callbacks
586586
@@after_fork_child_callbacks ||= [
587-
# clean ups (don't depend on event loop):
587+
# reinit event loop first:
588+
->{ Crystal::EventLoop.current.after_fork },
589+
590+
# reinit signal handling:
588591
->Crystal::System::Signal.after_fork,
589592
->Crystal::System::SignalChildHandler.after_fork,
590593

591-
# reinit event loop:
592-
->{ Crystal::EventLoop.current.after_fork },
593-
594-
# more clean ups (may depend on event loop):
594+
# additional reinitialization
595595
->Random::DEFAULT.new_seed,
596596
] of -> Nil
597597
end

0 commit comments

Comments
 (0)