-
Notifications
You must be signed in to change notification settings - Fork 282
feature: added the sig_restart API to the ngx.process module. #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This PR is clearly missing tests and documentation, which I can add if desired. |
lib/ngx/process.lua
Outdated
| void ngx_http_lua_ffi_process_signal_graceful_exit(void); | ||
| int ngx_http_lua_ffi_master_pid(void); | ||
| int ngx_http_lua_ffi_enable_sa_restart(int signum, int enabled); | ||
| char *strerror(int errnum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imho, this might belong to another cdef definition, if so please let me know where.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to break encapsulation. Better make the ngx_http_lua_ffi_enable_sa_restart() API function itself return the error string, just like our other C API functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, will change it 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Is it looking good enough for tests and documentation?
0f9aac4 to
f10aff8
Compare
lib/ngx/process.lua
Outdated
| void ngx_http_lua_ffi_process_signal_graceful_exit(void); | ||
| int ngx_http_lua_ffi_master_pid(void); | ||
| int ngx_http_lua_ffi_enable_sa_restart(int signum, int enabled); | ||
| char *strerror(int errnum); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to break encapsulation. Better make the ngx_http_lua_ffi_enable_sa_restart() API function itself return the error string, just like our other C API functions?
f10aff8 to
5b0f12f
Compare
|
@thibaultcha This PR LGTM. Although I am thinking if we could add some constants for common POSIX signals to make using this easier? Providing numbers directly is not always convenient. See: http://man7.org/linux/man-pages/man7/signal.7.html section "Standard signals". |
|
@dndx I thought about doing so but I wasn't sure where to put them (somewhere on the |
|
@thibaultcha What about |
|
@dndx If we hard-code them in the Lua-land, my only concern is portability. If we do so, should we only provide constants for those signals that are defined as the same across all architectures? |
|
@thibaultcha Yes. I think we can just provide the ones in https://en.wikipedia.org/wiki/Signal_(IPC) that has "Portable number" assigned from POSIX and leave the rest to the user. |
|
@dndx Works for me. |
5b0f12f to
b08d156
Compare
|
@dndx Added |
b08d156 to
da51a1f
Compare
|
Closing this PR as it seems the |
This is one of 4 PRs to properly handle
EINTRerrors in resty-cli (and/or OpenResty if desired by the user).SA_RESTARTon signal handlerssig_restart()APISA_RESTARTflag on interrupting signalsIf all PRs are merged:
io.popen()popen crashes in resty but not in luajit resty-cli#35