110 |
|
#endif |
111 |
|
#if defined(LINUX) || defined(CYGWIN) |
112 |
|
if ((f=fopen("/proc/stat", "r" ))==NULL) { |
113 |
< |
sg_set_error(SG_ERROR_OPEN, "/proc/stat"); |
113 |
> |
sg_set_error_with_errno(SG_ERROR_OPEN, "/proc/stat"); |
114 |
|
return NULL; |
115 |
|
} |
116 |
|
/* The very first line should be cpu */ |
132 |
|
#if defined(FREEBSD) || defined(DFBSD) |
133 |
|
size = sizeof cp_time; |
134 |
|
if (sysctlbyname("kern.cp_time", &cp_time, &size, NULL, 0) < 0){ |
135 |
< |
sg_set_error(SG_ERROR_SYSCTLBYNAME, "kern.cp_time"); |
135 |
> |
sg_set_error_with_errno(SG_ERROR_SYSCTLBYNAME, "kern.cp_time"); |
136 |
|
return NULL; |
137 |
|
} |
138 |
|
#else |
145 |
|
size = sizeof cp_time; |
146 |
|
if (sysctl(mib, 2, &cp_time, &size, NULL, 0) < 0) { |
147 |
|
#ifdef NETBSD |
148 |
< |
sg_set_error(SG_ERROR_SYSCTL, "CTL_KERN.KERN_CP_TIME"); |
148 |
> |
sg_set_error_with_errno(SG_ERROR_SYSCTL, |
149 |
> |
"CTL_KERN.KERN_CP_TIME"); |
150 |
|
#else |
151 |
< |
sg_set_error(SG_ERROR_SYSCTL, "CTL_KERN.KERN_CPTIME"); |
151 |
> |
sg_set_error_with_errno(SG_ERROR_SYSCTL, |
152 |
> |
"CTL_KERN.KERN_CPTIME"); |
153 |
|
#endif |
154 |
|
return NULL; |
155 |
|
} |