lib/browsermob/proxy/server.rb in browsermob-proxy-0.0.2 vs lib/browsermob/proxy/server.rb in browsermob-proxy-0.0.3
- old
+ new
@@ -25,10 +25,13 @@
def start
@process.start
sleep 0.1 until listening?
+ pid = Process.pid
+ at_exit { stop if Process.pid == pid }
+
self
end
def url
"http://localhost:#{port}"
@@ -37,20 +40,10 @@
def create_proxy
Client.from url
end
def stop
- return unless @process.alive?
-
- begin
- @process.poll_for_exit(5)
- rescue ChildProcess::TimeoutError
- @process.stop
- end
- rescue Errno::ECHILD
- # already dead
- ensure
- @process = nil
+ @process.stop if @process.alive?
end
private
\ No newline at end of file