Suppose I need to save the state of some structure before the end of the program. The program ends non-deterministic. Is there any way from the inside to understand that the program will now be completed and perform the save, or is it something on the verge of madness?

    1 answer 1

    There is atexit , but in general, if the data is important, it is better to save them in advance.

    • From documentation: Functions thus registered are automatically executed upon __normal__ interpreter termination - MaxU
    • @MaxU, because I clarified that it is better to save important data otherwise. With something besides the “normal termination” to save the data, I believe, will not work. - Surfin Bird
    • При чём-то помимо «normal termination» сохранить данные, полагаю, никак не выйдет. - agree - MaxU