<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p>Hi,</p>
<p>Function <code>ngx_slprintf</code> 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).</p>
<p>However regarding the function <code>ngx_log_error</code> (or rather <code>ngx_log_error_core</code> invoked internally) it is a bit more complex (there are still structures like <code>log, <code>log->connection</code></code> 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 <code>write</code> (being async-signal-safe corresponding POSIX) using stderr handler.<br /><br />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.</p>
<p>Regards,<br />Sergey.</p>
<p>05.11.2022 21:32, Nikhil Singhal wrote:</p>
<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->
<div dir="ltr">Hi All,<br /><br />Wanted to know if ngx_log_error and ngx_slprintf functions are async signal safe or not. Any help would be appreciated.<br /><br />
<div>Regards,</div>
<div>Nikhil Singhal</div>
</div>
<br />
<pre>_______________________________________________
nginx-devel mailing list -- <a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a>
To unsubscribe send an email to <a href="mailto:nginx-devel-leave@nginx.org">nginx-devel-leave@nginx.org</a>
</pre>
</blockquote>
</body></html>