io = IO.popen("cd doc && jekyll serve --watch")
pid = io.pid
# Inspired by http://stackoverflow.com/questions/14635318/having-a-io-popen-command-be-killed-when-the-caller-process-is-killed
Signal.trap("INT") {
# Ctrl-C was pressed...
puts "Shutting down Jekyll..."
Process.kill("INT", pid)
io.close
exit 0
}
while line = io.gets do
puts line
end
Sample code from running Jekyll via Ruby:
end