diff options
| author | Matt Robinson <matt@puppetlabs.com> | 2011-02-15 17:10:42 -0800 |
|---|---|---|
| committer | Matt Robinson <matt@puppetlabs.com> | 2011-02-16 15:13:31 -0800 |
| commit | 7cb884e44db412ed4cc19d9eb3e07d4b5b17f6b3 (patch) | |
| tree | 783ca4c23a65eef0201e08925221f63458a0c31c /lib/puppet/application/queue.rb | |
| parent | 9b7b0f3ad87abc3a6fbb7ad128e942571cd3e71a (diff) | |
| download | puppet-7cb884e44db412ed4cc19d9eb3e07d4b5b17f6b3.tar.gz puppet-7cb884e44db412ed4cc19d9eb3e07d4b5b17f6b3.tar.xz puppet-7cb884e44db412ed4cc19d9eb3e07d4b5b17f6b3.zip | |
(#6346) Move the trap calls onto Signal so they're easier to stub
Once you stub signal traps in tests, you can hit ctrl+c in the middle of
a spec run and it will stop the run instead of puppet catching the
SIGINT.
I had trouble easily tracking down all the places to stub traps when the
trap was being called as a private method on applications and daemons,
but calling trap on Signal is equivalent since Kernel calls Signal.trap
and Object mixes in Kernel to provide trap as a private method on all
objects.
A bigger solution would be to refactor everywhere we call trap into a
method that's called consistently since right now we sprinkle SIGINT and
SIGTERM trap handling over applications and daemons in inconsistent
ways, returning different error codes and using different messages.
I've captured this info in ticket #6345.
Reviewed-by: Jacob Helwig <jacob@puppetlabs.com>
Diffstat (limited to 'lib/puppet/application/queue.rb')
| -rw-r--r-- | lib/puppet/application/queue.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/puppet/application/queue.rb b/lib/puppet/application/queue.rb index 239f6b2ad..ede47d0a6 100644 --- a/lib/puppet/application/queue.rb +++ b/lib/puppet/application/queue.rb @@ -15,13 +15,13 @@ class Puppet::Application::Queue < Puppet::Application # Do an initial trap, so that cancels don't get a stack trace. # This exits with exit code 1 - trap(:INT) do + Signal.trap(:INT) do $stderr.puts "Caught SIGINT; shutting down" exit(1) end # This is a normal shutdown, so code 0 - trap(:TERM) do + Signal.trap(:TERM) do $stderr.puts "Caught SIGTERM; shutting down" exit(0) end |
