How to avoid memory leak when user press ctrl+c under linux?

前端 未结 7 2011
眼角桃花
眼角桃花 2020-12-29 15:28

In my program written with C and C++, I will new an object to fulfill the task, then delete the object.

At the moment after new object but before delete object, if t

7条回答
  •  隐瞒了意图╮
    2020-12-29 15:54

    Pressing CtrlC will send a SIGINT to the process, which by default does a mostly-orderly shutdown, including tearing down the memory manager and releasing all allocated heap and stack. If you need to perform other tasks then you will need to install a SIGINT handler and perform those tasks yourself.

提交回复
热议问题