diff options
author | Christian Göttsche <cgzones@googlemail.com> | 2024-01-09 23:57:40 +0100 |
---|---|---|
committer | BenBE <BenBE@geshi.org> | 2024-01-10 09:44:36 +0100 |
commit | 2b6304cec56272f28a305a3099bdb5f996c829ce (patch) | |
tree | 5386edbc215528ad01d66955839a4ad31e41d70e | |
parent | f9fb93aaf8712934ee0c78d5d887882fd29b6e36 (diff) |
Linux: use fseek(3)
Use fseek(3) instead of rewind(3) to check for success.
-rw-r--r-- | linux/LinuxProcess.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/linux/LinuxProcess.c b/linux/LinuxProcess.c index c2039796..dc4f2594 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); |