Skip to content

Commit 9f2d3b3

Browse files
committed
feature: added an FFI API for setting the SA_RESTART flag on given
signals.
1 parent 91a0ad2 commit 9f2d3b3

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/ngx_http_lua_worker.c

+32
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,36 @@ ngx_http_lua_ffi_process_signal_graceful_exit(void)
190190
{
191191
ngx_quit = 1;
192192
}
193+
194+
195+
int
196+
ngx_http_lua_ffi_enable_sa_restart(int signum, int enabled)
197+
{
198+
#if !(NGX_WIN32)
199+
struct sigaction act;
200+
201+
if (ngx_process != NGX_PROCESS_WORKER
202+
&& ngx_process != NGX_PROCESS_SINGLE)
203+
{
204+
return NGX_DECLINED;
205+
}
206+
207+
if (sigaction(signum, NULL, &act) != 0) {
208+
return NGX_ERROR;
209+
}
210+
211+
if (enabled) {
212+
act.sa_flags |= SA_RESTART;
213+
214+
} else {
215+
act.sa_flags &= ~SA_RESTART;
216+
}
217+
218+
if (sigaction(signum, &act, NULL) != 0) {
219+
return NGX_ERROR;
220+
}
221+
#endif
222+
223+
return NGX_OK;
224+
}
193225
#endif

0 commit comments

Comments
 (0)