problem with sysctlbyname on 10.4 or ppc
problem with sysctlbyname on 10.4 or ppc
- Subject: problem with sysctlbyname on 10.4 or ppc
- From: "Vianney Lecroart" <email@hidden>
- Date: Wed, 20 Feb 2008 17:16:27 +0100
Hello darwin dev,
I use sysctlbyname() to get some information like kern.version.
It works fine on my mac (10.5 on i386) but on the mac of one of my
client, he have this error:
Can't get 'kern.version' from sysctl: Bad file descriptor
When I asked him to do a sysctl -A, I saw that kern.version is available:
http://pastebin.com/f395945d
What can be the problem?
The code (c++) I used to get sysctl:
string getsysctlstr(const string &name)
{
string value("Unknown");
size_t len;
char *p;
if(sysctlbyname(name.c_str(), NULL, &len, NULL, 0) == 0)
{
p = (char*)malloc(len);
if(sysctlbyname(name.c_str(), p, &len, NULL, 0) == 0)
{
value = p;
}
else
{
nlwarning("SI: Can't get '%s' from sysctl: %s", name.c_str(),
strerror (errno));
}
free(p);
}
else
{
nlwarning("SI: Can't get '%s' from sysctl: %s", name.c_str(),
strerror (errno));
}
return value;
}
--
Vianney Lecroart
http://www.mtp-target.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden