diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2014-05-03 15:33:48 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2014-05-03 15:33:48 -0700 |
commit | 56bf209f84d91d905dfd61905713c9c52b590872 (patch) | |
tree | 3f66090d00459f1f2d3f078aead64fa88f6155cf /history.cpp | |
parent | 186b0f62ebf34a446730d45a0a27a51be335df24 (diff) | |
parent | 333fb1bf97e53725b730fa7047e1873cacceed44 (diff) |
Merge branch 'master' into death_of_fishd
Conflicts:
configure.ac
Diffstat (limited to 'history.cpp')
-rw-r--r-- | history.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/history.cpp b/history.cpp index 4f6e9006..fdbc2359 100644 --- a/history.cpp +++ b/history.cpp @@ -1364,12 +1364,20 @@ bool history_t::save_internal_via_rewrite() for (size_t attempt = 0; attempt < 10 && out_fd == -1; attempt++) { char *narrow_str = wcs2str(tmp_name_template.c_str()); +#if HAVE_MKOSTEMP + out_fd = mkostemp(narrow_str, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC | O_CLOEXEC); + if (out_fd >= 0) + { + tmp_name = str2wcstring(narrow_str); + } +#else if (narrow_str && mktemp(narrow_str)) { /* It was successfully templated; try opening it atomically */ tmp_name = str2wcstring(narrow_str); out_fd = wopen_cloexec(tmp_name, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC, 0644); } +#endif free(narrow_str); } |