ngx_log_error, ngx_slprintf signal safe
Sergey Brester
serg.brester at sebres.de
Mon Nov 7 11:37:30 UTC 2022
Hi,
Function ngx_slprintf is conditionally async-signal safe (unless you'd
use the same buffer, supplied as first argument, or free such buffer or
some of the arguments in signal handler, because the function is not
atomic and can be interrupted by a signal).
However regarding the function ngx_log_error (or rather
ngx_log_error_core invoked internally) it is a bit more complex (there
are still structures like log, log->connection etc used internally,
which must remain unchanged unless the function ends), but you can safe
call the function inside the handler, because it fills the buffer in
stack before logging it in one piece hereafter with function write
(being async-signal-safe corresponding POSIX) using stderr handler.
In my opinion it is safe to call both functions inside the async-signal
handler, but you should avoid to "touch" the structures and arguments
(e. g. release or modify them) that can be used in invocations of that
functions outside.
Regards,
Sergey.
05.11.2022 21:32, Nikhil Singhal wrote:
> Hi All,
>
> Wanted to know if ngx_log_error and ngx_slprintf functions are async signal safe or not. Any help would be appreciated.
>
> Regards,
> Nikhil Singhal
>
> _______________________________________________
> nginx-devel mailing list -- nginx-devel at nginx.org
> To unsubscribe send an email to nginx-devel-leave at nginx.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20221107/e9afb1fa/attachment.htm>
More information about the nginx-devel
mailing list