I want a minimal o-damn-malloc-just-failed handler, which writes some info to a file (probably just standard error). I would prefer to use fprintf() rather than write(), bu
The C standard doesn't guarantee that fprintf
won't call malloc
under the hood. Indeed, it doesn't guarantee anything about what happens when you override malloc
. You should refer to the documentation for your specific C library, or simply write your own fprintf
-like function which makes direct syscalls, avoiding any possibility of heap allocation.