summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 937e151..3169068 100644
--- a/src/main.c
+++ b/src/main.c
@@ -61,7 +61,7 @@ void sigint_handler(int sig) {
#define CONF_ENO 1
void save_config() {
- FILE* config = fopen("conf.dmp", "w");
+ FILE* config = fopen("conf.dmp.tmp", "w");
if(config == NULL)
fatal("Couldn't open config for writing");
@@ -77,8 +77,11 @@ void save_config() {
if(fwrite(peer_table, sizeof(struct peer_entry), peer_table_size, config) != peer_table_size)
fatal("Couldn't write peer table");
+ fflush(config);
if(fclose(config) != 0)
fatal("Couldn't close config file");
+
+ rename("conf.dmp.tmp", "conf.dmp");
}
int read_config() {