commit - 154fe22a526e064cce847afa71d8c833a008bd7d
commit + 3e36ea51f650498b743754daa74d4aa039129956
blob - 29dd22293830349fed6858a83f1c516bd2b6862b
blob + 23d9e0bb5edc8cc2d93bdb7ebb000798766902bb
--- session.c
+++ session.c
void
save_session(void)
{
- FILE *tmp;
+ FILE *tmp, *hist;
struct tab *tab;
size_t i;
int fd, err= 0;
if (rename(sfn, session_file))
return;
- strlcpy(sfn, history_file_tmp, sizeof(sfn));
- if ((fd = mkstemp(sfn)) == -1 ||
- (tmp = fdopen(fd, "w")) == NULL) {
- if (fd != -1) {
- unlink(sfn);
- close(fd);
- }
+ if ((hist = fopen(history_file, "a")) == NULL)
return;
- }
if (history.dirty) {
for (i = 0; i < history.len && history.dirty > 0; ++i) {
history.dirty--;
history.items[i].dirty = 0;
- fprintf(tmp, "%lld %s\n",
+ fprintf(hist, "%lld %s\n",
(long long)history.items[i].ts,
history.items[i].uri);
}
history.dirty = 0;
}
- err = ferror(tmp);
- fclose(tmp);
-
- if (err) {
- unlink(sfn);
- return;
- }
-
- rename(sfn, history_file);
+ err = ferror(hist);
+ fclose(hist);
}
void