I have a class that may be something like this:
class StreetSim{
public:
void operator(){
//do cool things
if(street_exploded) exit(5);
}
};
This works great for a small program like this:
int main(){
StreetSim ss;
ss();
return 0;
}
However now I want to embed this in another program. I would really like to not fork the process as a child, but I'm not allowed to change StreetSim
. I would prefer something like this:
int main(){
StreetSim ss;
int k = catch(ss());
if(k==5)
fprintf("the street exploded!");
return k;
}
Is it at all possible to catch a program exit signal like this? I suspect not, but perhaps some gurus here might have some useful tribal knowledge about something like this.