Hello Sami, [...] > Oh sorry, I mixed up terminology. Okay. > Allocated memory can be > passed to on_exit() and nothing else makes sense. While one could pass > global variable to on_exit() in that case more portable atexit() is better > option. I'm not sure that's correct. Particularly as the same exit handler function may be registered with pointers to different global variables. I applied the patch below. Thanks, Michael diff --git a/man3/on_exit.3 b/man3/on_exit.3 index d2c2c3b17..e78b5c818 100644 --- a/man3/on_exit.3 +++ b/man3/on_exit.3 @@ -100,6 +100,16 @@ It no longer occurs in Solaris (SunOS 5). Portable application should avoid this function, and use the standard .BR atexit (3) instead. +.SH NOTES +By the time +.I function +is executed, stack +.RI ( auto ) +variables may already have gone out of scope. +Therefore, +.I arg +should not be a pointer to a stack variable; +it may however be a pointer to a heap variable or a global variable. .SH SEE ALSO .BR _exit (2), .BR atexit (3), -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/