Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::signal

 

std::signal is an STL function to set a function to respond to system signals.

 

In the example below, an assert is set to fail, causing std::abort, which emits the abort signal ('SIGABRT'). With std::signal onAbort is set to handle this.

 

#include <cassert>
#include <csignal>
#include <iostream>

void onAbort(int)
{
  std::cout << "Abort" << std::endl;
}

int main()
{
  std::signal(SIGABRT,onAbort);
  assert(1==2);
}

 

 

 

 

 

Signal pages

 

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict