Klaus Demo nginx / 9eaabc6
use sys_errlist[] in signal handler instead of non Async-Signal-Safe strerror_r() Igor Sysoev 12 years ago
3 changed file(s) with 29 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
132132 . auto/feature
133133
134134
135 ngx_feature="sys_errlist[]"
136 ngx_feature_name="NGX_HAVE_SYS_ERRLIST"
137 ngx_feature_run=yes
138 ngx_feature_incs="#include <stdio.h>"
139 ngx_feature_path=
140 ngx_feature_libs=
141 ngx_feature_test="int n = sys_nerr; const char *p = sys_errlist[1];"
142 . auto/feature
143
144
135145 ngx_feature="localtime_r()"
136146 ngx_feature_name="NGX_HAVE_LOCALTIME_R"
137147 ngx_feature_run=no
6363
6464 /* Solaris and Tru64 UNIX have thread-safe strerror() */
6565
66 #define ngx_strerror_r(err, errstr, size) \
66 #define ngx_strerror_r(err, errstr, size) \
6767 ngx_cpystrn(errstr, (u_char *) strerror(err), size)
6868
6969 #endif
7070
7171
72 #if (NGX_HAVE_SYS_ERRLIST)
73
74 #define ngx_sigsafe_strerror(err) \
75 (err > 0 && err < sys_nerr) ? sys_errlist[err] : "Unknown error"
76
77 #else
78
79 #define ngx_sigsafe_strerror(err) ""
80
81 #endif
82
83
7284 #endif /* _NGX_ERRNO_H_INCLUDED_ */
478478 */
479479
480480 if (err == NGX_ECHILD) {
481 ngx_log_error(NGX_LOG_INFO, ngx_cycle->log, errno,
482 "waitpid() failed");
481 ngx_log_error(NGX_LOG_INFO, ngx_cycle->log, 0,
482 "waitpid() failed (%d: %s)",
483 err, ngx_sigsafe_strerror(err));
483484 return;
484485 }
485486
486487 #endif
487488
488 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, errno,
489 "waitpid() failed");
490
489 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,
490 "waitpid() failed (%d: %s)",
491 err, ngx_sigsafe_strerror(err));
491492 return;
492493 }
493494