Fix jekyll serve --detach with jekyll-sass-converter 3.x (#9304)

Merge pull request 9304
This commit is contained in:
なつき
2023-02-21 14:57:03 -08:00
committed by GitHub
parent ecf098580d
commit 16a1e5cac4
2 changed files with 39 additions and 0 deletions

View File

@@ -274,12 +274,19 @@ module Jekyll
def boot_or_detach(server, opts)
if opts["detach"]
pid = Process.fork do
# Detach the process from controlling terminal
$stdin.reopen("/dev/null", "r")
$stdout.reopen("/dev/null", "w")
$stderr.reopen("/dev/null", "w")
server.start
end
Process.detach(pid)
Jekyll.logger.info "Server detached with pid '#{pid}'.",
"Run `pkill -f jekyll' or `kill -9 #{pid}' to stop the server."
# Exit without running `at_exit` inherited by the forked process.
Process.exit! 0
else
t = Thread.new { server.start }
trap("INT") { server.shutdown }