Linux C catching kill signal for graceful termination

后端 未结 3 1372
無奈伤痛
無奈伤痛 2020-12-05 11:02

I have a process using sockets, database connections and the likes. It is basically a server process relaying between sensor data and a web interface, and as such it is impo

3条回答
  •  既然无缘
    2020-12-05 11:37

    You install signal handlers to catch signals -- however in 99% of cases you just want to exit and let the Linux OS take care of the cleanup -- it will happily close all files, sockets, free memory and shutdown threads.

    So unless there is anything specifically you want to do, like sending a message on the sockets, then you should just exit from the process and not try to catch the signal.

提交回复
热议问题