It all depends on what your program does, but I would say something like this:
Graceful completion means that all "running" I / O operations (eg, reading files, HTTP request / responses, etc.) must complete, but new functions cannot be started. Thus, your shutdown handler should prevent the possibility of starting any new operations (for example, cancel any port listeners, prevent any new fs calls, etc.), ensure that the currently executing handlers are executed until completion, and then exit the process .
[Edit] Of course, if your application does not care about the above issues, then there really is nothing to do. When the process ends, all open file / socket descriptors will be automatically closed, so there are no problems with resource leaks.
maerics Feb 15 '12 at 18:48 2012-02-15 18:48
source share