aboutsummaryrefslogtreecommitdiff
path: root/editor.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2015-07-17 14:38:36 +0200
committerMarc André Tanner <mat@brain-dump.org>2015-07-19 14:12:43 +0200
commit0fa9885cda0778467ca5737ac888ece5ef371b3d (patch)
treefd3ab531ec8ab1e60b9ee9a782c2c38120202d7b /editor.c
parent8129933ca51caf788e0cd7c5fdbcb43fdc64601d (diff)
downloadvis-0fa9885cda0778467ca5737ac888ece5ef371b3d.tar.gz
vis-0fa9885cda0778467ca5737ac888ece5ef371b3d.tar.xz
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
Diffstat (limited to 'editor.c')
-rw-r--r--editor.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/editor.c b/editor.c
index ad9bd4e..8628458 100644
--- a/editor.c
+++ b/editor.c
@@ -358,6 +358,8 @@ void editor_window_close(Win *win) {
ed->windows = win->next;
if (ed->win == win)
ed->win = win->next ? win->next : win->prev;
+ if (ed->prompt_window == win)
+ ed->prompt_window = NULL;
window_free(win);
if (ed->win)
ed->ui->window_focus(ed->win->ui);