From: o7si Date: Mon, 29 Dec 2025 09:07:49 +0000 (+0800) Subject: common: fix return value check for setpriority (#18412) X-Git-Tag: upstream/0.0.7599~31 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=daa242dfc88e80df2d60bc5e8fd4d2fffa3e220c;p=pkg%2Fggml%2Fsources%2Fllama.cpp common: fix return value check for setpriority (#18412) * common: fix return value check for setpriority * tools: add logging for process priority setting --- diff --git a/common/common.cpp b/common/common.cpp index 8d628933..58fef595 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -251,7 +251,7 @@ bool set_process_priority(enum ggml_sched_priority prio) { case GGML_SCHED_PRIO_REALTIME: p = -20; break; } - if (!setpriority(PRIO_PROCESS, 0, p)) { + if (setpriority(PRIO_PROCESS, 0, p) != 0) { LOG_WRN("failed to set process priority %d : %s (%d)\n", prio, strerror(errno), errno); return false; } diff --git a/tools/completion/completion.cpp b/tools/completion/completion.cpp index 29770515..a9eda119 100644 --- a/tools/completion/completion.cpp +++ b/tools/completion/completion.cpp @@ -175,7 +175,10 @@ int main(int argc, char ** argv) { struct ggml_threadpool_params tpp = ggml_threadpool_params_from_cpu_params(params.cpuparams); - set_process_priority(params.cpuparams.priority); + if (!set_process_priority(params.cpuparams.priority)) { + LOG_ERR("%s: error: failed to set process priority\n", __func__); + return 1; + } struct ggml_threadpool * threadpool_batch = NULL; if (!ggml_threadpool_params_match(&tpp, &tpp_batch)) { diff --git a/tools/llama-bench/llama-bench.cpp b/tools/llama-bench/llama-bench.cpp index b431c7f3..a98ede0a 100644 --- a/tools/llama-bench/llama-bench.cpp +++ b/tools/llama-bench/llama-bench.cpp @@ -2037,7 +2037,10 @@ int main(int argc, char ** argv) { llama_backend_init(); llama_numa_init(params.numa); - set_process_priority(params.prio); + if (!set_process_priority(params.prio)) { + fprintf(stderr, "%s: error: failed to set process priority\n", __func__); + return 1; + } // initialize printer std::unique_ptr p = create_printer(params.output_format);