opsengine/cpulimit

cannot compile on Fedora 33 64bits

ROBERT-MCDOWELL opened this issue · 2 comments

hello,

here is the log

cd src && make all
make[1]: Entering directory '/home/src/cpulimit/src'
cc -o cpulimit cpulimit.c list.o process_iterator.o process_group.o -Wall -g -D_GNU_SOURCE
cpulimit.c:41:10: fatal error: sys/sysctl.h: No such file or directory
41 | #include <sys/sysctl.h>
| ^~~~~~~~~~~~~~
compilation terminated.
make[1]: *** [Makefile:15: cpulimit] Error 1

This is because Fedora 33 has GLIBC 2.32, however, GLIBC 2.32 has removed sys/sysctl.h header file.
You can find this change in GLIBC 2.32 Release Note

This probably needs the author to fix.

This patch is a quick fix for this issue:

diff --git a/src/cpulimit.c b/src/cpulimit.c
index 50eabea..eba4615 100644
--- a/src/cpulimit.c
+++ b/src/cpulimit.c
@@ -38,12 +38,14 @@
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+#ifdef __APPLE__
 #include <sys/sysctl.h>
+#endif
 #include <sys/resource.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 
-#ifdef __APPLE__ || __FREEBSD__
+#if defined(__APPLE__) || defined(__FREEBSD__)
 #include <libgen.h>
 #endif