mirror of
https://github.com/Cisco-Talos/clamav.git
synced 2025-10-19 10:23:17 +00:00
clamd: Fix bug reporting memory stats, used by clamdtop
ClamD's STATS API reports process memory stats on systems that provide the `mallinfo()` system call. This feature is used by ClamDTOP to show process memory usage. When we switched to the CMake build system, we neglected to add the check for the `mallinfo()` system call and so broke ClamD memory usage reporting. This commit adds the CMake check for `mallinfo()` and sets HAVE_MALLINFO, if found. Fixes: https://github.com/Cisco-Talos/clamav/issues/706 Jira: CLAM-2742
This commit is contained in:
parent
492e505070
commit
18120a0ef0
3 changed files with 36 additions and 0 deletions
|
@ -778,6 +778,8 @@ include(CheckFTS)
|
|||
include(CheckUnamePosix)
|
||||
# Check support for file descriptor passing
|
||||
include(CheckFDPassing)
|
||||
# Check support for mallinfo memory stats
|
||||
include(CheckMallinfo)
|
||||
|
||||
# Check if big-endian
|
||||
include(TestBigEndian)
|
||||
|
|
8
cmake/CheckMallinfo.c
Normal file
8
cmake/CheckMallinfo.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
#include <malloc.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
struct mallinfo mi;
|
||||
mi = mallinfo();
|
||||
return 0;
|
||||
}
|
26
cmake/CheckMallinfo.cmake
Normal file
26
cmake/CheckMallinfo.cmake
Normal file
|
@ -0,0 +1,26 @@
|
|||
#
|
||||
# Check for mallinfo(3) sys call.
|
||||
#
|
||||
|
||||
GET_FILENAME_COMPONENT(_selfdir_CheckMallinfo
|
||||
"${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
|
||||
# Check that the POSIX compliant uname(2) call works properly (HAVE_UNAME_SYSCALL)
|
||||
try_run(
|
||||
# Name of variable to store the run result (process exit status; number) in:
|
||||
test_run_result
|
||||
# Name of variable to store the compile result (TRUE or FALSE) in:
|
||||
test_compile_result
|
||||
# Binary directory:
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
# Source file to be compiled:
|
||||
${_selfdir_CheckMallinfo}/CheckMallinfo.c
|
||||
# Where to store the output produced during compilation:
|
||||
COMPILE_OUTPUT_VARIABLE test_compile_output
|
||||
# Where to store the output produced by running the compiled executable:
|
||||
RUN_OUTPUT_VARIABLE test_run_output )
|
||||
|
||||
# Did compilation succeed and process return 0 (success)?
|
||||
if("${test_compile_result}" AND ("${test_run_result}" EQUAL 0))
|
||||
set(HAVE_MALLINFO 1)
|
||||
endif()
|
Loading…
Add table
Add a link
Reference in a new issue