dirtyhenry / buckygem

⚽️ A gem for random ruby utilities. 💎
MIT License
0 stars 0 forks source link

Create convenient tool to launch interactive shell script via ruby #5

Closed dirtyhenry closed 4 years ago

dirtyhenry commented 8 years ago

Sample code from running Jekyll via Ruby:

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

end

dirtyhenry commented 4 years ago

I don't really see the point of this anymore.