From eb24df9749994d175a2de3b7fc0535abe46a7576 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 13 Mar 2016 20:23:41 -0500 Subject: Split out _xexit() from xexit() and give sigatexit() multiple callbacks. --- www/code.html | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'www') diff --git a/www/code.html b/www/code.html index 7e15e181..c133611c 100644 --- a/www/code.html +++ b/www/code.html @@ -632,13 +632,28 @@ itoa().

errors, to eliminate common error checking. This prints an error message and the strerror() string for the errno encountered.

-

You can intercept this exit by assigning a setjmp/longjmp buffer to +

We replaced exit(), _exit(), and atexit() with xexit(), _xexit(), and +sigatexit(). This gives _xexit() the option to siglongjmp(toys.rebound, 1) +instead of exiting, lets xexit() report stdout flush failures to stderr +and change the exit code to indicate error, lets our toys.exit function +change happen for signal exit paths and lets us remove the functions +after we've called them.

+ +

You can intercept our exit by assigning a setjmp/longjmp buffer to toys.rebound (set it back to zero to restore the default behavior). If you do this, cleaning up resource leaks is your problem.