Settings: check if writing configuration file was successful

Writing to the file stream might fail due to a immutable file or a
filesystem error.
Check the error indicator for the stream and for fclose() failures.
This commit is contained in:
Christian Göttsche
2021-03-12 16:56:06 +01:00
parent 350b48e44c
commit 521f1343e3
3 changed files with 16 additions and 8 deletions

9
htop.c
View File

@ -482,8 +482,13 @@ int main(int argc, char** argv) {
Platform_done();
CRT_done();
if (settings->changed)
Settings_write(settings);
if (settings->changed) {
int r = Settings_write(settings);
if (r < 0)
fprintf(stderr, "Can not save configuration to %s: %s\n", settings->filename, strerror(-r));
}
Header_delete(header);
ProcessList_delete(pl);