From 2b6304cec56272f28a305a3099bdb5f996c829ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 9 Jan 2024 23:57:40 +0100 Subject: [PATCH] Linux: use fseek(3) Use fseek(3) instead of rewind(3) to check for success. --- linux/LinuxProcess.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index c20397964..dc4f2594d 100644 --- a/linux/LinuxProcess.c +++ b/linux/LinuxProcess.c @@ -196,13 +196,10 @@ static bool LinuxProcess_changeAutogroupPriorityBy(Process* p, Arg delta) { long int identity; int nice; int ok = fscanf(file, "/autogroup-%ld nice %d", &identity, &nice); - bool success; - if (ok == 2) { - rewind(file); + bool success = false; + if (ok == 2 && fseek(file, 0L, SEEK_SET) == 0) { xSnprintf(buffer, sizeof(buffer), "%d", nice + delta.i); success = fputs(buffer, file) > 0; - } else { - success = false; } fclose(file);