Issue #11092 has been updated by Josh Cooper.

Status changed from Unreviewed to Accepted
Target version set to 2.7.x

This would be useful, e.g. to diagnose #10955. You could get the call stack as:

<pre>
if signal == :INT and Puppet[:trace]
  Kernel.caller.each { |frame| puts "  #{frame}" }
end
</pre>

Also, it'd be nice to have this work across all puppet applications, not just 
daemonized ones, especially as daemonizing is not supported on Windows
----------------------------------------
Feature #11092: when running under --trace, a backtrace from the SIGINT handler 
would be useful
https://projects.puppetlabs.com/issues/11092

Author: Kjetil Torgrim Homme
Status: Accepted
Priority: Normal
Assignee: 
Category: 
Target version: 2.7.x
Affected Puppet version: 
Keywords: 
Branch: 


I had an agent just spinning on CPU, seemingly doing nothing.  Running under 
--debug didn't really tell me anything, and --trace had no effect.  It would be 
useful if I could get a Ruby backtrace when I pressed ^C.

in my local copy, I changed daemon.rb:set_signal_traps:

<pre>
   def set_signal_traps
     signals = {:INT => :stop, :TERM => :stop }
     # extended signals not supported under windows
     signals.update({:HUP => :restart, :USR1 => :reload, :USR2 => :reopen_logs 
}) unless Puppet.features.microsoft_windows?
     signals.each do |signal, method|
       Signal.trap(signal) do
         Puppet.notice "Caught #{signal}; calling #{method}"
+        if signal == :INT and Puppet[:trace]
+          begin
+            raise Exception.exception("SIG#{signal} received")
+          rescue => detail
+            puts detail.backtrace
+          end
+        end
         send(method)
       end
     end
   end
</pre>

This works, but there may be a more elegant way to get hold of a backtrace :-)  
You may want to test for Puppet[:debug] as well as Puppet[:trace], but I think 
few people will be surprised to see a backtrace when they press ^C in trace 
mode.



-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to