From 666c92fa76c71a146b1810c7e917c8a13a0afc58 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sat, 6 Sep 2014 02:20:25 +0200 Subject: [PATCH] Check whether the nice() function is available refs #7115 --- CMakeLists.txt | 1 + config.h.cmake | 1 + lib/base/process.cpp | 2 ++ 3 files changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 404947b26..2990b4ac1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,6 +133,7 @@ endif() check_function_exists(vfork HAVE_VFORK) check_function_exists(backtrace_symbols HAVE_BACKTRACE_SYMBOLS) check_function_exists(pipe2 HAVE_PIPE2) +check_function_exists(nice HAVE_NICE) check_library_exists(dl dladdr "dlfcn.h" HAVE_DLADDR) check_library_exists(execinfo backtrace_symbols "" HAVE_LIBEXECINFO) check_include_file_cxx(cxxabi.h HAVE_CXXABI_H) diff --git a/config.h.cmake b/config.h.cmake index 0df4bb2c1..b537096f8 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -8,6 +8,7 @@ #cmakedefine HAVE_DLADDR #cmakedefine HAVE_LIBEXECINFO #cmakedefine HAVE_CXXABI_H +#cmakedefine HAVE_NICE #cmakedefine ICINGA2_UNITY_BUILD diff --git a/lib/base/process.cpp b/lib/base/process.cpp index 96efbb080..9ad9197ae 100644 --- a/lib/base/process.cpp +++ b/lib/base/process.cpp @@ -527,8 +527,10 @@ void Process::Run(const boost::function& callback) (void)close(fds[0]); (void)close(fds[1]); +#ifdef HAVE_NICE if (nice(5) < 0) Log(LogWarning, "base", "Failed to renice child process."); +#endif /* HAVE_NICE */ if (icinga2_execvpe(argv[0], argv, envp) < 0) { char errmsg[512]; -- 2.40.0