]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
common: fix return value check for setpriority (#18412)
authoro7si <redacted>
Mon, 29 Dec 2025 09:07:49 +0000 (17:07 +0800)
committerGitHub <redacted>
Mon, 29 Dec 2025 09:07:49 +0000 (11:07 +0200)
* common: fix return value check for setpriority

* tools: add logging for process priority setting

common/common.cpp
tools/completion/completion.cpp
tools/llama-bench/llama-bench.cpp

index 8d62893370fd4c016b4cb0e148729efaa91437e9..58fef595468c05f408f1fd7200da2f72ba4a6948 100644 (file)
@@ -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;
     }
index 29770515f557a716d1fb393c9cf37eb03287da39..a9eda119d72c70361ef63233c6d45e0f9f298c4d 100644 (file)
@@ -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)) {
index b431c7f31bf754291168eda6685f522573cfa4f2..a98ede0a57cbb136888bede854f73fb03678db86 100644 (file)
@@ -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<printer> p     = create_printer(params.output_format);