23static int fd_stderr_original = -1;
24static int fd_stdout[2];
25static int fd_stderr[2];
29 int fd = open(
"/dev/null", O_RDWR);
45static inline int fpm_use_error_log(
void) {
83 if (0 > fd_stderr_original) {
84 zlog(
ZLOG_SYSERROR,
"failed to save original STDERR fd, access.log records may appear in error_log: dup()");
94 if (-1 != fd_stderr_original) {
97 zlog(
ZLOG_SYSERROR,
"failed to restore original STDERR fd, access.log records may appear in error_log: dup2()");
100 if (close_after_restore) {
101 close(fd_stderr_original);
111 if (fpm_use_error_log()) {
128 if (fpm_use_error_log()) {
162#define FPM_STDIO_CMD_FLUSH "\0fscf"
169static void fpm_stdio_child_said(
struct fpm_event_s *ev,
short which,
void *
arg)
176 int in_buf = 0, cmd_pos = 0,
pos,
start;
177 int read_fail = 0, create_log_stream;
187 event = &child->ev_stdout;
189 event = &child->ev_stderr;
193 if (create_log_stream) {
199 child->
wp->
config->
name, (
int) child->
pid, is_stdout ?
"stdout" :
"stderr");
210 child->
wp->
config->
name, (
int) child->
pid, is_stdout ?
"stdout" :
"stderr");
218 in_buf = read(
fd,
buf,
sizeof(
buf) - 1);
222 read_fail = (in_buf < 0) ? in_buf : 1;
253 cmd_pos = in_buf -
pos;
266 if (create_log_stream) {
271 zlog(
ZLOG_SYSERROR,
"unable to read what child %d said into %s", (
int) child->
pid, is_stdout ?
"stdout" :
"stderr");
294 if (0 > pipe(fd_stdout)) {
299 if (0 > pipe(fd_stderr)) {
306 if (0 > fd_set_blocked(fd_stdout[0], 0) || 0 > fd_set_blocked(fd_stderr[0], 0)) {
376 if (fpm_use_error_log()) {
396 if (fpm_use_error_log()) {
zend_ffi_ctype_name_buf buf
struct fpm_globals_s fpm_globals
struct fpm_global_config_s fpm_global_config
int fpm_event_set(struct fpm_event_s *ev, int fd, int flags, void(*callback)(struct fpm_event_s *, short, void *), void *arg)
int fpm_event_add(struct fpm_event_s *ev, unsigned long int frequency)
int fpm_event_del(struct fpm_event_s *ev)
int fpm_stdio_init_child(struct fpm_worker_pool_s *wp)
int fpm_stdio_flush_child(void)
int fpm_stdio_discard_pipes(struct fpm_child_s *child)
#define FPM_STDIO_CMD_FLUSH
int fpm_stdio_init_final(void)
int fpm_stdio_redirect_stderr_to_error_log(void)
void fpm_stdio_child_use_pipes(struct fpm_child_s *child)
int fpm_stdio_prepare_pipes(struct fpm_child_s *child)
int fpm_stdio_redirect_stderr_to_dev_null_for_syslog(void)
int fpm_stdio_open_error_log(int reopen)
int fpm_stdio_save_original_stderr(void)
int fpm_stdio_parent_use_pipes(struct fpm_child_s *child)
int fpm_stdio_init_main(void)
int fpm_stdio_restore_original_stderr(int close_after_restore)
#define STREAM_SET_MSG_PREFIX_FMT
unsigned const char * pos
#define PHP_IS_TRANSIENT_ERROR(err)
void php_openlog(const char *ident, int option, int facility)
struct fpm_worker_pool_s * wp
struct zlog_stream * log_stream
int decorate_workers_output
struct fpm_worker_pool_config_s * config
strcmp(string $string1, string $string2)
#define strcasecmp(s1, s2)
ZEND_DLIMPORT int isatty(int fd)
zlog_bool zlog_stream_finish(struct zlog_stream *stream)
void zlog_set_launched(void)
ssize_t zlog_stream_str(struct zlog_stream *stream, const char *str, size_t str_len)
void zlog_stream_init_ex(struct zlog_stream *stream, int flags, int fd)
zlog_bool zlog_stream_set_msg_prefix(struct zlog_stream *stream, const char *fmt,...)
void zlog_stream_set_child_pid(struct zlog_stream *stream, int child_pid)
void zlog_stream_set_msg_quoting(struct zlog_stream *stream, zlog_bool quote)
zlog_bool zlog_stream_set_msg_suffix(struct zlog_stream *stream, const char *suffix, const char *final_suffix)
void zlog_stream_set_decorating(struct zlog_stream *stream, zlog_bool decorate)
void zlog_stream_set_is_stdout(struct zlog_stream *stream, zlog_bool is_stdout)
void zlog_stream_set_wrapping(struct zlog_stream *stream, zlog_bool wrap)
int zlog_set_fd(int new_fd, zlog_bool is_stderr)