From 0fa9885cda0778467ca5737ac888ece5ef371b3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Fri, 17 Jul 2015 14:38:36 +0200 Subject: vis: handle file truncation more gracefully If we use the file / virtual memory system as cache (using mmap(2)) and another process truncates the file we are editing, we have a problem. All we can do is catch the resulting SIGBUS, close the corresponding window and print a warning message. To test this use: $ dd if=/dev/zero of=TEST bs=8M count=1 $ vis TEST :! echo TRUNCATE > TEST --- text.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'text.h') diff --git a/text.h b/text.h index c322a10..89a5d9b 100644 --- a/text.h +++ b/text.h @@ -108,6 +108,9 @@ size_t text_history_get(Text*, size_t index); size_t text_size(Text*); /* query whether the text contains any unsaved modifications */ bool text_modified(Text*); +/* query whether `addr` is part of a memory mapped region associated with + * this text instance */ +bool text_sigbus(Text*, const char *addr); /* which type of new lines does the text use? */ enum TextNewLine { -- cgit v1.2.3