Advertisement

Exception handling problem

Started by March 19, 2008 07:00 AM
2 comments, last by Peter_APIIT 16 years, 7 months ago
I'm a bit new to programming for Linux so i was suprised that try..catch block didn't catch an exception that was trown when my code was trying to write something to the beginning of RAM. I only saw "SegmentationFault" as program output so i'm wondering how to handle segmentation faults in C++ on Linux. Thanks in advance.
ubuntu jaunty amd64
In C++ try/catch blocks are only guaranteed to catch C++ exceptions: exceptions thrown with the throw keyword. Segmentation faults are handled with POSIX signals on linux, in particular, SIGSEGV. For more information use man signal.
Advertisement
Thanks a lot. I just forgot about signals)))
ubuntu jaunty amd64
This is the syntax of exception handling in C++.

try
{
}
catch() // Derived class
{
}
catch()
{
}
catch()
{
}

This notation go from specific class to general situation.

This topic is closed to new replies.

Advertisement