J
Jim King
A is an RAII class.
int main()
{
A a;
(void)a;
return 0;
}
Definitely, object "a" will be destructed.
Now, let's use exit().
int main()
{
A a;
(void)a;
exit(0);
}
The destructor of object "a" is not invoked.
Question 1: Can I force stack unwinding and destruct "a" before
invoking exit()?
Suppose we are in a signal handler:
void sig_handler()
{
exit(3);
}
So, local objects will not be destructed.
Question 2: Is there any way that all local objects will be destructed
when our customized signal handler chooses to terminate the process?
int main()
{
A a;
(void)a;
return 0;
}
Definitely, object "a" will be destructed.
Now, let's use exit().
int main()
{
A a;
(void)a;
exit(0);
}
The destructor of object "a" is not invoked.
Question 1: Can I force stack unwinding and destruct "a" before
invoking exit()?
Suppose we are in a signal handler:
void sig_handler()
{
exit(3);
}
So, local objects will not be destructed.
Question 2: Is there any way that all local objects will be destructed
when our customized signal handler chooses to terminate the process?