06/04/09 - joe turner <joe@agavemountain.com> 20 Minute Code Review Agave Mountain Agave Mountain, Inc. Joe Turner
06/04/09 - joe turner <joe@agavemountain.com> 1.   Signal Handler / Back Trace
06/04/09 - joe turner <joe@agavemountain.com> Signal handler registered and is called :  CTRL-C stops application Bus faul...
06/04/09 - joe turner <joe@agavemountain.com> glibc now has a built in functions for generating a backtrace.  **See speake...
The End. and happily ever after. 06/04/09 - joe turner <joe@agavemountain.com>
Upcoming SlideShare
Loading in …5
×

Simple 20 Minute Code Review

1,552 views

Published on

A very simple code review example.

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,552
On SlideShare
0
From Embeds
0
Number of Embeds
22
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Simple 20 Minute Code Review

    1. 1. 06/04/09 - joe turner <joe@agavemountain.com> 20 Minute Code Review Agave Mountain Agave Mountain, Inc. Joe Turner
    2. 2. 06/04/09 - joe turner <joe@agavemountain.com> 1. Signal Handler / Back Trace
    3. 3. 06/04/09 - joe turner <joe@agavemountain.com> Signal handler registered and is called : CTRL-C stops application Bus fault Floating point exception segment fault etc… Calls back_trace() and/or prints out signal # Signal Handler static void sig_handler(int signum) { switch (signum) { case SIGHUP: case SIGINT: case SIGILL: case SIGBUS: case SIGFPE: case SIGSEGV: case SIGTERM: case SIGSTKFLT: back_trace(); default: printf(&quot;Caught signal %d &quot;, signum); }; exit(0); }
    4. 4. 06/04/09 - joe turner <joe@agavemountain.com> glibc now has a built in functions for generating a backtrace. **See speaker’s notes for the glibc documentation. back_trace() static void back_trace(void) { int c, i; void *addresses[10]; char **strings; c = backtrace(addresses, 10); strings = backtrace_symbols(addresses,c); printf(&quot;backtrace returned: %d &quot;, c); for(i = 0; i < c; i++) { printf(&quot;%d: %X &quot;, i, (int)addresses[i]); printf(&quot;%s &quot;, strings[i]); } free (strings); }
    5. 5. The End. and happily ever after. 06/04/09 - joe turner <joe@agavemountain.com>

    ×