Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
#include <setjmp.h> 
#include <signal.h> 
 
static jmp_buf env; 
 
void int_handler() { 
  longjmp(env, 1); 
} 
 
int main() { 
  char *foo; 

  signal(SIGINT, int_handler); 
 
  if(setjmp(env) == 0) { 
    foo = malloc(15);
    strcpy(foo =, "Nothing yet.");
  }
  else {
    strcpy(foo =, "Signal caught.");
  }

  /* main loop which displays foo */

  return 0;
}

...

Code Block
bgColor#ccccff
#include <setjmp.h> 
#include <signal.h> 
 
static jmp_buf env; 
int interrupted = 0;
 
void int_handler() { 
  interrupted = 1;
} 
 
int main() { 
  char *foo; 

  signal(SIGINT, int_handler); 
    
  foo = malloc(15);
  strcpy(foo, = "Nothing yet.");
  
  /* main loop which displays foo */
  if(interruptinterrupted == 1) {
    strcpy(foo, = "Signal caught.");
  }

  return 0;
}

Risk Assessment

...

Wiki Markup
\[[ISO/IEC 03|AA. C References#ISO/IEC 03]\] "Signals and Interrupts"
\[[Open Group 04|AA. C References#Open Group 04]\] [longjmp|http://www.opengroup.org/onlinepubs/000095399/functions/longjmp.html]
\[OpenBSD\] [{{signal()}} Man Page|http://www.openbsd.org/cgi-bin/man.cgi?query=signal]
\[Zalewski 01\] [http://lcamtuf.coredump.cx/signals.txt]