Quote:
I also have this simple question: Why not use async-unsafe functions after all? The worse thing that could happen would be the application to crash or to be in a loop easily terminated with SIGKILL.
I think you just answered your own question.
Quote:
The application was going to forcefully terminate after all. At least give it a chance to do a proper cleanup.
You can give it more than a chance -- you can actually
do so. Async-safe system calls include open(), close(), read(), and write() among many other things. All you need.
fopen, printf() and its relatives in particular are
not signal safe because they allocate memory. You might get away with it by accident but it's system-dependent, compiler-dependent, library-dependent, and luck-dependent. Your code may work all the time on your system and
crash all the time on someone else's.
To write code that'll work both here and there, use signal-safe things. That's what they're for.