Running single binary/process on linux/unix
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#include <iostream>
#include <signal.h>
using namespace std;
//void SignalHandler(int signal)
//{
// printf("Segmentation fault...\n");
// exit(0);
//}
class crash
{
public:
crash()
{
std::cout << "crash()" << std::endl;
}
void crashbin()
{
char *ptr;
strcpy((ptr + 100), "you are killed");
}
~crash()
{
std::cout << "~crash()" << std::endl;
}
};
void main()
{
//signal(SIGSEGV, SignalHandler);
try
{
crash c;
c.crashbin();
}
catch(...)
{
std::cout << "i cought segmentation fault" << std::endl;
}
return;
}
|
now the destructor will not run in this case, uncomment the lines and see the difference.
Last edited on
Topic archived. No new replies allowed.