Re: fc5 C system call always returning -1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 21, 2006 at 05:21:40PM -0700, Greg Frinchaboy wrote:
 > This may be an old issue but I could not find info in the archives.
 > 
 > u_int num_cpus = system("cat /proc/cpuinfo | grep -c processor > 
 > /dev/null");
 > 
 > Has yielded the number of cpus on the system since I used it in RH7.3 
 > and fc3.
 > Now in fc5, all uses of system("cmd");  return -1
 > 
 > The command executes OK, just the return value is always -1.
 > 
 > u_int num_cpus = system("cat /proc/cpuinfo");
 > dumps the cpuinfo file to the system console
 > 
 > u_int num_cpus = system("cat /proc/cpuinfo | grep -c processor");
 > dumps a 2 to the system console, etc.
 > 
 > Any help would be appreciated...

u_int num_cpus = sysconf(_SC_NPROCESSORS_CONF);

should always do the right thing. Your grep won't.
(hint: There are CPUs that have the string 'processor'
in the model name field of /proc/cpuinfo

	Dave

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux