lib/guard/yard/server.rb in guard-yard-2.1.0 vs lib/guard/yard/server.rb in guard-yard-2.1.1

- old
+ new

@@ -11,28 +11,27 @@ @stderr = options[:stderr] @cli = options[:cli] end def spawn - self.pid = fork - raise 'Fork failed' if pid == -1 + UI.info "[Guard::Yard] Starting YARD Documentation Server." - unless pid - Signal.trap('QUIT', 'IGNORE') - Signal.trap('INT', 'IGNORE') - Signal.trap('TSTP', 'IGNORE') + command = ["yard server -p #{port}"] + command << @cli if @cli + command << "2> #{@stderr}" if @stderr + command << "1> #{@stdout}" if @stdout - command = ["yard server -p #{port}"] - command << @cli if @cli - command << "2> #{@stderr}" if @stderr - command << "1> #{@stdout}" if @stdout - exec command.join(' ') - end - pid + self.pid = Process.spawn(command.join(' ')) end def kill - Process.kill('KILL', pid) unless pid.nil? + UI.info "[Guard::Yard] Stopping YARD Documentation Server." + begin + Process.kill('QUIT', pid) if pid + Process.wait2 + rescue Errno::ESRCH, Errno::ECHILD + # Process is already dead. + end true end def verify 5.times do