The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
MMU exception Puntino Linux 2 05-07-2008 09:35 AM
How to catch the exception Vijayakumarpc UNIX for Dummies Questions & Answers 0 02-07-2007 11:18 PM
Help with RPC Exception ejbrever HP-UX 2 08-24-2006 11:08 AM
RPC Exception - Help ejbrever UNIX for Advanced & Expert Users 0 08-21-2006 09:56 AM
exception handling RichardS UNIX for Advanced & Expert Users 1 06-16-2004 02:29 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-05-2002
Registered User
 

Join Date: Dec 2001
Posts: 14
Question converting a signal to a C++ exception

I am trying to imitate a system call available on Win32
(spit). The functionality is to catch a system exception (i.e. signal)
such as divide-by-zero, and convert it to a catchable c++
exception. Can this be done on Unix ?
Can i use "throw new <ExcpetionClass>" inside a
signal-handling routine ?
I am using AIX.
Thank you for your time

Seeker
Reply With Quote
Forum Sponsor
  #2  
Old 02-13-2002
Registered User
 

Join Date: Feb 2002
Location: www.freebsdforums.org
Posts: 67
Have you tried it ?
__________________
FreeBSD: The best free Unix on this planet IMHO!!

FreeBSD Forums
www.freebsdforums.org
Reply With Quote
  #3  
Old 02-18-2002
Registered User
 

Join Date: Dec 2001
Posts: 14
No I have'nt - link problems

I will post a message here if I have any advances
Reply With Quote
  #4  
Old 03-02-2002
Registered User
 

Join Date: Feb 2002
Location: Brabant, Belgium
Posts: 65
If you set up one handler for each, you will get this to work under Linux.

#include <iostream.h>
#include <stdlib.h>
#include <signal.h>

class sx {
public:
sx(int sig) {
cout << "Signal " << sig << " caught\n";
}
};

void handler(int s)
{
cout << "yes, I'm here\n";
new sx(s);
exit(0);
}

main(int ac, char *av[])
{
signal(SIGINT, handler);
for (;;
}

Press Ctl-C, and you will get two messages, the signal number is random, because of the this pointer.


Atle
__________________
PS
All of the above is to be read as '... unless I am wrong'
ENDPS
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:30 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0