diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-11-25 12:17:05 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-11-25 12:17:05 -0800 |
commit | 3f5bbc8516073d6af7b6d2aa9b46bc09af57c880 (patch) | |
tree | 9dedba993240faf798f567672b70cbf9daf3cf6e /spec/tiny_server.rb | |
parent | 26dbab99fd9aea988195f027975963db14a9de87 (diff) | |
download | chef-3f5bbc8516073d6af7b6d2aa9b46bc09af57c880.tar.gz |
fix rspecs-ctrl-clcg/fix-rspec-ctrl-c
we can't fork off tinyserver without a lot of work in the test
codebase, so instead save a copy of the old rspec signal handler and then
after tinyserver has started (and we're sure that rack has scribbled
over the signal handler), restore the rspec signal handler.
there's an obvious race if someone hits ctrl-c after tinyserver has
scribbled over the sigint handler but before we restore it, but this is
99.9% better of a solution than nothing.
Diffstat (limited to 'spec/tiny_server.rb')
-rw-r--r-- | spec/tiny_server.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/spec/tiny_server.rb b/spec/tiny_server.rb index a2cfe168d5..c28fdc30b3 100644 --- a/spec/tiny_server.rb +++ b/spec/tiny_server.rb @@ -1,6 +1,6 @@ # # Author:: Daniel DeLeo (<dan@opscode.com>) -# Copyright:: Copyright (c) 2010 Opscode, Inc. +# Copyright:: Copyright (c) 2010-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -66,9 +66,11 @@ module TinyServer @server = Server.setup(@options) do run API.instance end + @old_handler = trap(:INT, "EXIT") @server.start end block_until_started + trap(:INT, @old_handler) end def url |