Bug 80778 - foldingathome-5.0.2-r1 CPU Count incorrect
Bug#: 80778 Product:  Gentoo Linux Version: unspecified Platform: x86
OS/Version: All Status: RESOLVED Severity: minor Priority: P2
Resolution: FIXED Assigned To: sci@gentoo.org Reported By: andy.dalton@gmail.com
Component: Applications
URL: 
Summary: foldingathome-5.0.2-r1 CPU Count incorrect
Keywords:  
Status Whiteboard: 
Opened: 2005-02-04 14:07 0000
Description:   Opened: 2005-02-04 14:07 0000
The /etc/init.d/foldingathome startup scripts attempts to identify a CPU count
automatically if the CPU variable is set to 0 in /etc/conf.d/foldingathome. 
The code that does that is the following:

    if [ -z "${CPU}" ] || [ "${CPU}" == "0" ]; then
        if [ -r /proc/cpuinfo ]; then
            CPU=`grep processor </proc/cpuinfo | wc -l`
        else
            CPU=1
        fi
    fi

The problem is, however, the word 'processor' can appear in different places. 
Consider the following output I get by running the command manually:

# grep processor </proc/cpuinfo
processor       : 0
model name      : AMD Athlon(tm) processor

Here, I only have a single CPU, but the script determines I have two.  I
suggest revising the script as follows:

replace
    CPU=`grep processor </proc/cpuinfo | wc -l`
with
    CPU=`grep "^processor.*:" /proc/cpuinfo | wc -l`

This way, the pattern matched is restricted to lines starting with the word
processor, followed by some number of characters, followed by a colon.

Thanks,

Andy Dalton

------- Comment #1 From Brandon Low (RETIRED) 2005-02-05 16:54:48 0000 -------
Thanks, making -r3 with this change.