• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
problem with sysctlbyname on 10.4 or ppc
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: problem with sysctlbyname on 10.4 or ppc
      • From: Terry Lambert <email@hidden>
  • Prev by Date: USB device prevented from mounting
  • Next by Date: A Couple launchd user agent questions
  • Previous by thread: Re: USB device prevented from mounting
  • Next by thread: Re: problem with sysctlbyname on 10.4 or ppc
  • Index(es):
    • Date
    • Thread