From 74fdde9fec6053f1af66e2eabe42c052de2551c3 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Mon, 27 Oct 2014 13:22:40 -0400 Subject: Added the catch-all case to falsehoods about shutdown hooks. (Thanks, @idcmp!) --- wiki/dev/shutdown-hooks.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'wiki/dev/shutdown-hooks.md') diff --git a/wiki/dev/shutdown-hooks.md b/wiki/dev/shutdown-hooks.md index 62b5d76..bf6b304 100644 --- a/wiki/dev/shutdown-hooks.md +++ b/wiki/dev/shutdown-hooks.md @@ -24,4 +24,6 @@ The following beliefs are widespread and incorrect: 5. **Your shutdown hook will be the only thing running.** In languages that support “daemon” threads, shutdown hooks may start before daemon threads terminate. In languages with concurrent shutdown hooks, other hooks will be in flight at the same time. On POSIX platforms, signals can still arrive during your shutdown hook. (Did you start any child processes? `SIGCHLD` can still arrive.) +6. **You need a shutdown hook.** Closing files, terminating threads, and hanging up network connections are all done automatically by the OS as part of process destruction. The behaviour of the final few writes to a file handle aren't completely deterministic (unflushed data can be lost), but that's true even if a shutdown hook tries to close the file. + Programs that rely on shutdown hooks for correctness should be treated as de-facto incorrect, much like object finalization in garbage-collected languages. -- cgit v1.2.3