3 * Copyright (C) Igor Sysoev
7 #include <ngx_config.h>
13 ngx_int_t ngx_max_sockets;
14 ngx_uint_t ngx_inherited_nonblocking;
15 ngx_uint_t ngx_tcp_nodelay_and_tcp_nopush;
21 ngx_os_io_t ngx_os_io = {
32 ngx_os_init(ngx_log_t *log)
36 #if (NGX_HAVE_OS_SPECIFIC_INIT)
37 if (ngx_os_specific_init(log) != NGX_OK) {
42 ngx_init_setproctitle(log);
44 ngx_pagesize = getpagesize();
45 ngx_cacheline_size = NGX_CPU_CACHE_LINE;
49 for (n = ngx_pagesize; n >>= 1; ngx_pagesize_shift++) { /* void */ }
57 if (getrlimit(RLIMIT_NOFILE, &rlmt) == -1) {
58 ngx_log_error(NGX_LOG_ALERT, log, errno,
59 "getrlimit(RLIMIT_NOFILE) failed)");
63 ngx_max_sockets = (ngx_int_t) rlmt.rlim_cur;
65 #if (NGX_HAVE_INHERITED_NONBLOCK)
66 ngx_inherited_nonblocking = 1;
68 ngx_inherited_nonblocking = 0;
78 ngx_os_status(ngx_log_t *log)
80 ngx_log_error(NGX_LOG_NOTICE, log, 0, NGINX_VER);
83 ngx_log_error(NGX_LOG_NOTICE, log, 0, "built by " NGX_COMPILER);
86 #if (NGX_HAVE_OS_SPECIFIC_INIT)
87 ngx_os_specific_status(log);
90 ngx_log_error(NGX_LOG_NOTICE, log, 0,
91 "getrlimit(RLIMIT_NOFILE): %r:%r",
92 rlmt.rlim_cur, rlmt.rlim_max);
97 ngx_posix_post_conf_init(ngx_log_t *log)
101 if (pipe(pp) == -1) {
102 ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "pipe() failed");
106 if (dup2(pp[1], STDERR_FILENO) == -1) {
107 ngx_log_error(NGX_LOG_EMERG, log, errno, "dup2(STDERR) failed");
111 if (pp[1] > STDERR_FILENO) {
112 if (close(pp[1]) == -1) {
113 ngx_log_error(NGX_LOG_EMERG, log, errno, "close() failed");