aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-11-20 15:21:49 +0100
committerMarc André Tanner <mat@brain-dump.org>2015-11-20 15:21:49 +0100
commit697bc0ebc8178488cdb837b584b47d965b421b48 (patch)
tree7f9d6f287bf69bd94e434c93aadbfabc1772ca2f
parent9bf0e704d094bfa9c82ddb45aa7797014832469e (diff)
downloadvis-697bc0ebc8178488cdb837b584b47d965b421b48.tar.gz
vis-697bc0ebc8178488cdb837b584b47d965b421b48.tar.xz
text: get modification time after replacing file content in place
At the start of text_save_range we stat(2) the file to check whether we have currently mmap(2)-ed it. Then we proceed to write the new file content which changes modification time. Hence we have to stat(2) again to retrieve it. This should fix spurious warnings about file changes outside the editor when editing e.g. symlinked files.
-rw-r--r--text.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/text.c b/text.c
index 92e961c..1e1c968 100644
--- a/text.c
+++ b/text.c
@@ -988,6 +988,8 @@ bool text_save_range(Text *txt, Filerange *range, const char *filename) {
if (fsync(fd) == -1)
goto err;
+ if (fstat(fd, &meta) == -1)
+ goto err;
if (close(fd) == -1)
return false;
txt->info = meta;