Skip to content

Commit

Permalink
Linux: use fseek(3)
Browse files Browse the repository at this point in the history
Use fseek(3) instead of rewind(3) to check for success.
  • Loading branch information
cgzones authored and BenBE committed Jan 10, 2024
1 parent f9fb93a commit 2b6304c
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions linux/LinuxProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2b6304c

Please sign in to comment.