Hi,
I had an hanging sysctl(8) that was compiled with an obsolete header
file. Struct sensordev was too small, so sysctl(2) failed with
ENOMEM. But the sysctl(8) program continued with unitialized memory.
# sysctl hw
...
hw.diskcount=2
hw.sensors..temp0=33.00 degC
--> here it hangs in an endless loop
So I would like to catch the error and skip the sensors.
# sysctl hw
...
hw.diskcount=2
sysctl: sensors dev 0: Cannot allocate memory
hw.cpuspeed=2933
...
ok?
bluhm
Index: sbin/sysctl/sysctl.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sbin/sysctl/sysctl.c,v
retrieving revision 1.240
diff -u -p -r1.240 sysctl.c
--- sbin/sysctl/sysctl.c 29 Jan 2019 14:07:15 -0000 1.240
+++ sbin/sysctl/sysctl.c 21 Feb 2019 14:45:52 -0000
@@ -2418,6 +2418,8 @@ sysctl_sensors(char *string, char **bufp
continue;
if (errno == ENOENT)
break;
+ warn("sensors dev %d", dev);
+ return (-1);
}
snprintf(buf, sizeof(buf), "%s.%s",
string, snsrdev.xname);
@@ -2443,6 +2445,8 @@ sysctl_sensors(char *string, char **bufp
continue;
if (errno == ENOENT)
break;
+ warn("sensors dev %d", dev);
+ return (-1);
}
if (strcmp(devname, snsrdev.xname) == 0)
break;