nginx 0.1.1
[nginx-catap.git] / src / os / unix / ngx_linux_init.c
blob3c7d34483933099e826cd434417f7210c9198d37
2 /*
3 * Copyright (C) Igor Sysoev
4 */
7 #include <ngx_config.h>
8 #include <ngx_core.h>
11 char ngx_linux_kern_ostype[50];
12 char ngx_linux_kern_osrelease[20];
14 int ngx_linux_rtsig_max;
17 ngx_os_io_t ngx_os_io = {
18 ngx_unix_recv,
19 ngx_readv_chain,
20 ngx_unix_send,
21 #if (HAVE_SENDFILE)
22 ngx_linux_sendfile_chain,
23 NGX_IO_SENDFILE
24 #else
25 ngx_writev_chain,
27 #endif
31 ngx_int_t ngx_os_init(ngx_log_t *log)
33 int name[2];
34 size_t len;
36 name[0] = CTL_KERN;
37 name[1] = KERN_OSTYPE;
38 len = sizeof(ngx_linux_kern_ostype);
39 if (sysctl(name, sizeof(name), ngx_linux_kern_ostype, &len, NULL, 0)
40 == -1) {
41 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
42 "sysctl(KERN_OSTYPE) failed");
43 return NGX_ERROR;
46 name[0] = CTL_KERN;
47 name[1] = KERN_OSRELEASE;
48 len = sizeof(ngx_linux_kern_osrelease);
49 if (sysctl(name, sizeof(name), ngx_linux_kern_osrelease, &len, NULL, 0)
50 == -1) {
51 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
52 "sysctl(KERN_OSRELEASE) failed");
53 return NGX_ERROR;
57 name[0] = CTL_KERN;
58 name[1] = KERN_RTSIGMAX;
59 len = sizeof(ngx_linux_rtsig_max);
60 if (sysctl(name, sizeof(name), &ngx_linux_rtsig_max, &len, NULL, 0) == -1) {
61 ngx_log_error(NGX_LOG_INFO, log, ngx_errno,
62 "sysctl(KERN_RTSIGMAX) failed");
63 ngx_linux_rtsig_max = 0;
67 ngx_init_setproctitle(log);
70 return ngx_posix_init(log);
74 void ngx_os_status(ngx_log_t *log)
76 ngx_log_error(NGX_LOG_INFO, log, 0, "OS: %s %s",
77 ngx_linux_kern_ostype, ngx_linux_kern_osrelease);
79 ngx_log_error(NGX_LOG_INFO, log, 0, "sysctl(KERN_RTSIGMAX): %d",
80 ngx_linux_rtsig_max);
83 ngx_posix_status(log);