ravinet/mahimahi — pull request #31 by anirudhSK (2013-10-16 02:39:13+00:00)
Title: DNAT Destructor bug fix

Ravi,

This is what you were asking me about today evening. The destructor gets called when the object goes out of scope. So if all goes well, and the program terminates normally, the destructor will be called at the end of main(), since DNAT is an object local to main().

However, when you terminate the process using a Ctrl+C, the OS does some default signal handling and doesn't terminate via main(). A good program will catch these signals on its own, and terminate gracefully, and in the process call its desctructors automatically.

This SO post may be instructive: http://stackoverflow.com/questions/4250013/is-destructor-called-if-sigint-or-sigstp-issued.

I didn't know this myself btw, so this isn't something obvious (the fact that destructors aren't called if the program terminates abnormally).

Anirudh