aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2011-09-10 18:17:57 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2011-09-10 18:17:57 (GMT)
commitf9df3ffedafe4ee36a74949958527ecc0c23c841 (patch)
tree2fa79619346e1a2b540d940703fa424cd69ba75c
parentb104d9e4d0fab70dd5bd3119e2808cd3fb02bffa (diff)
downloadfluxbox_paul-f9df3ffedafe4ee36a74949958527ecc0c23c841.zip
fluxbox_paul-f9df3ffedafe4ee36a74949958527ecc0c23c841.tar.bz2
sync the copied config files to disk before continuing
otherwise a race condition might appear between copying the default config files to .fluxbox/ and executing 'fluxbox-update_configs'. under macosx this lead to 'fluxbox hangs'.
-rw-r--r--src/main.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main.cc b/src/main.cc
index 00fa51f..26070dc 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -52,6 +52,10 @@
52 #include <string.h> 52 #include <string.h>
53#endif 53#endif
54 54
55#ifdef HAVE_UNISTD_H
56 #include <unistd.h>
57#endif
58
55#ifdef HAVE_SYS_STAT_H 59#ifdef HAVE_SYS_STAT_H
56#include <sys/types.h> 60#include <sys/types.h>
57#include <sys/stat.h> 61#include <sys/stat.h>
@@ -365,13 +369,19 @@ void setupConfigFiles(const std::string& dirname, const std::string& rc) {
365 } 369 }
366 } 370 }
367 371
372 bool sync_fs = false;
373
368 // copy default files if needed 374 // copy default files if needed
369 for (size_t i = 0; i < nr_of_cfiles; ++i) { 375 for (size_t i = 0; i < nr_of_cfiles; ++i) {
370 if (cfiles[i].create_file) { 376 if (cfiles[i].create_file) {
371 FbTk::FileUtil::copyFile(cfiles[i].default_name, cfiles[i].filename.c_str()); 377 FbTk::FileUtil::copyFile(cfiles[i].default_name, cfiles[i].filename.c_str());
378 sync_fs = true;
372 } 379 }
373 } 380 }
374 381
382 if (sync_fs) {
383 sync();
384 }
375} 385}
376 386
377 387
@@ -408,6 +418,7 @@ void updateConfigFilesIfNeeded(const std::string& rc_file) {
408 << commandargs 418 << commandargs
409 << "' failed." << endl; 419 << "' failed." << endl;
410 } 420 }
421 sync();
411 } 422 }
412} 423}
413 424