use sys_errlist[] in signal handler instead
of non Async-Signal-Safe strerror_r()
This commit is contained in:
parent
300def0abe
commit
8dd13e234f
3 changed files with 29 additions and 6 deletions
10
auto/unix
10
auto/unix
|
@ -133,6 +133,16 @@ ngx_feature_test="char buf[1024]; long n; n = strerror_r(1, buf, 1024);
|
||||||
. auto/feature
|
. auto/feature
|
||||||
|
|
||||||
|
|
||||||
|
ngx_feature="sys_errlist[]"
|
||||||
|
ngx_feature_name="NGX_HAVE_SYS_ERRLIST"
|
||||||
|
ngx_feature_run=yes
|
||||||
|
ngx_feature_incs="#include <stdio.h>"
|
||||||
|
ngx_feature_path=
|
||||||
|
ngx_feature_libs=
|
||||||
|
ngx_feature_test="int n = sys_nerr; const char *p = sys_errlist[1];"
|
||||||
|
. auto/feature
|
||||||
|
|
||||||
|
|
||||||
ngx_feature="localtime_r()"
|
ngx_feature="localtime_r()"
|
||||||
ngx_feature_name="NGX_HAVE_LOCALTIME_R"
|
ngx_feature_name="NGX_HAVE_LOCALTIME_R"
|
||||||
ngx_feature_run=no
|
ngx_feature_run=no
|
||||||
|
|
|
@ -64,10 +64,22 @@ u_char *ngx_strerror_r(int err, u_char *errstr, size_t size);
|
||||||
|
|
||||||
/* Solaris and Tru64 UNIX have thread-safe strerror() */
|
/* Solaris and Tru64 UNIX have thread-safe strerror() */
|
||||||
|
|
||||||
#define ngx_strerror_r(err, errstr, size) \
|
#define ngx_strerror_r(err, errstr, size) \
|
||||||
ngx_cpystrn(errstr, (u_char *) strerror(err), size)
|
ngx_cpystrn(errstr, (u_char *) strerror(err), size)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if (NGX_HAVE_SYS_ERRLIST)
|
||||||
|
|
||||||
|
#define ngx_sigsafe_strerror(err) \
|
||||||
|
(err > 0 && err < sys_nerr) ? sys_errlist[err] : "Unknown error"
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define ngx_sigsafe_strerror(err) ""
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif /* _NGX_ERRNO_H_INCLUDED_ */
|
#endif /* _NGX_ERRNO_H_INCLUDED_ */
|
||||||
|
|
|
@ -479,16 +479,17 @@ ngx_process_get_status(void)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (err == NGX_ECHILD) {
|
if (err == NGX_ECHILD) {
|
||||||
ngx_log_error(NGX_LOG_INFO, ngx_cycle->log, errno,
|
ngx_log_error(NGX_LOG_INFO, ngx_cycle->log, 0,
|
||||||
"waitpid() failed");
|
"waitpid() failed (%d: %s)",
|
||||||
|
err, ngx_sigsafe_strerror(err));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, errno,
|
ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,
|
||||||
"waitpid() failed");
|
"waitpid() failed (%d: %s)",
|
||||||
|
err, ngx_sigsafe_strerror(err));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue