diff options
author | Robert Pogorzelski <thinkingpotato@gmail.com> | 2013-05-24 18:56:40 +0200 |
---|---|---|
committer | Robert Pogorzelski <thinkingpotato@gmail.com> | 2013-05-24 18:56:40 +0200 |
commit | d03a935c09c29c2af98d2dc9c33937de2c83862a (patch) | |
tree | 9dc211ac8439d72510d9b9a8eb3bd657499ddf55 | |
parent | 794336e939f7562d03a24c52ab650d8b6b960e99 (diff) | |
download | cpulimit-d03a935c09c29c2af98d2dc9c33937de2c83862a.tar.gz |
[Related to #21] cpulimit doesn't handle multi core systems.
-rw-r--r-- | src/cpulimit.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cpulimit.c b/src/cpulimit.c index b031441..9b25b87 100644 --- a/src/cpulimit.c +++ b/src/cpulimit.c @@ -46,6 +46,10 @@ #include "process_group.h" #include "list.h" +#ifdef HAVE_SYS_SYSINFO_H +#include <sys/sysinfo.h> +#endif + #ifdef __APPLE__ #include "memrchr.c" #endif @@ -150,6 +154,8 @@ static int get_ncpu() { int mib[2] = {CTL_HW, HW_NCPU}; size_t len = sizeof(ncpu); sysctl(mib, 2, &ncpu, &len, NULL, 0); +#elif defined _GNU_SOURCE + ncpu = get_nprocs(); #endif return ncpu; } |