diff options
author | Igor Sysoev <igor@sysoev.ru> | 2008-11-11 22:44:30 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2008-11-11 22:44:30 +0300 |
commit | a25d29ff6fc0fedae6abcfe5e794ebf8cff14d8d (patch) | |
tree | 8f9261cb91fd91e5b6b0ed5988149217d16617fb /src/os | |
parent | f2884e194ab1bfe7bec979d04b21dc5f5e4a3628 (diff) |
the sysctl "kern.ostype" and "kern.osrelease" had appeared in MacOSX 10.5 only
Diffstat (limited to 'src/os')
-rw-r--r-- | src/os/unix/ngx_darwin_init.c | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/src/os/unix/ngx_darwin_init.c b/src/os/unix/ngx_darwin_init.c index c10196c62..67133198b 100644 --- a/src/os/unix/ngx_darwin_init.c +++ b/src/os/unix/ngx_darwin_init.c @@ -64,31 +64,43 @@ ngx_os_specific_init(ngx_log_t *log) ngx_uint_t i; size = sizeof(ngx_darwin_kern_ostype); - if (sysctlbyname("kern.ostype", - ngx_darwin_kern_ostype, &size, NULL, 0) == -1) { - ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, - "sysctlbyname(kern.ostype) failed"); + if (sysctlbyname("kern.ostype", ngx_darwin_kern_ostype, &size, NULL, 0) + == -1) + { + err = ngx_errno; - if (ngx_errno != NGX_ENOMEM) { - return NGX_ERROR; - } + if (err != NGX_ENOENT) { - ngx_darwin_kern_ostype[size - 1] = '\0'; + ngx_log_error(NGX_LOG_ALERT, log, err, + "sysctlbyname(kern.ostype) failed"); + + if (err != NGX_ENOMEM) { + return NGX_ERROR; + } + + ngx_darwin_kern_ostype[size - 1] = '\0'; + } } size = sizeof(ngx_darwin_kern_osrelease); - if (sysctlbyname("kern.osrelease", - ngx_darwin_kern_osrelease, &size, NULL, 0) == -1) { - ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, - "sysctlbyname(kern.osrelease) failed"); + if (sysctlbyname("kern.osrelease", ngx_darwin_kern_osrelease, &size, + NULL, 0) + == -1) + { + err = ngx_errno; - if (ngx_errno != NGX_ENOMEM) { - return NGX_ERROR; - } + if (err != NGX_ENOENT) { - ngx_darwin_kern_osrelease[size - 1] = '\0'; - } + ngx_log_error(NGX_LOG_ALERT, log, err, + "sysctlbyname(kern.osrelease) failed"); + if (err != NGX_ENOMEM) { + return NGX_ERROR; + } + + ngx_darwin_kern_osrelease[size - 1] = '\0'; + } + } for (i = 0; sysctls[i].name; i++) { size = sysctls[i].size; @@ -136,8 +148,10 @@ ngx_os_specific_status(ngx_log_t *log) u_long value; ngx_uint_t i; - ngx_log_error(NGX_LOG_NOTICE, log, 0, "OS: %s %s", - ngx_darwin_kern_ostype, ngx_darwin_kern_osrelease); + if (ngx_darwin_kern_ostype[0]) { + ngx_log_error(NGX_LOG_NOTICE, log, 0, "OS: %s %s", + ngx_darwin_kern_ostype, ngx_darwin_kern_osrelease); + } for (i = 0; sysctls[i].name; i++) { if (sysctls[i].exists) { |