Merge pull request #11048 from opensourcerouting/fix/fsync_before_fclose

vtysh: Call fflush+fsync before calling fclose() when saving the config
This commit is contained in:
Donald Sharp 2022-04-19 18:37:18 -04:00 committed by GitHub
commit 4069e53960
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3361,6 +3361,18 @@ int vtysh_write_config_integrated(void)
err++;
}
if (fflush(fp) != 0) {
printf("%% Warning: fflush() failed on %s: %s\n", frr_config,
safe_strerror(errno));
err++;
}
if (fsync(fd) < 0) {
printf("%% Warning: fsync() failed on %s: %s\n", frr_config,
safe_strerror(errno));
err++;
}
fclose(fp);
printf("Integrated configuration saved to %s\n", frr_config);