--- embedaddon/lighttpd/src/log.c 2013/10/14 10:32:47 1.1.1.1 +++ embedaddon/lighttpd/src/log.c 2014/06/15 20:20:06 1.1.1.2 @@ -122,9 +122,7 @@ int open_logfile_or_pipe(server *srv, const char* logf return -1; } -#ifdef FD_CLOEXEC - fcntl(fd, F_SETFD, FD_CLOEXEC); -#endif + fd_close_on_exec(fd); return fd; } @@ -178,9 +176,7 @@ int log_error_open(server *srv) { if (srv->errorlog_mode == ERRORLOG_FD) { srv->errorlog_fd = dup(STDERR_FILENO); -#ifdef FD_CLOEXEC - fcntl(srv->errorlog_fd, F_SETFD, FD_CLOEXEC); -#endif + fd_close_on_exec(srv->errorlog_fd); } if (-1 == (breakage_fd = open_logfile_or_pipe(srv, logfile))) { @@ -231,10 +227,7 @@ int log_error_cycle(server *srv) { /* ok, new log is open, close the old one */ close(srv->errorlog_fd); srv->errorlog_fd = new_fd; -#ifdef FD_CLOEXEC - /* close fd on exec (cgi) */ - fcntl(srv->errorlog_fd, F_SETFD, FD_CLOEXEC); -#endif + fd_close_on_exec(srv->errorlog_fd); } } @@ -369,6 +362,7 @@ static void log_write(server *srv, buffer *b) { case ERRORLOG_FILE: case ERRORLOG_FD: buffer_append_string_len(b, CONST_STR_LEN("\n")); + force_assert(b->used > 0); write(srv->errorlog_fd, b->ptr, b->used - 1); break; case ERRORLOG_SYSLOG: