Skip to content

Commit

Permalink
In follow mode, reopen file if it shrinks.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Jan 30, 2015
1 parent 9e14d60 commit 72d9c93
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ch.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,16 @@ ch_get()
#if HAVE_STAT_INO
if (follow_mode == FOLLOW_NAME)
{
/* See whether the file's i-number has changed.
/* See whether the file's i-number has changed,
* or the file has shrunk.
* If so, force the file to be closed and
* reopened. */
struct stat st;
POSITION curr_pos = ch_tell();
int r = stat(get_filename(curr_ifile), &st);
if (r == 0 && (st.st_ino != curr_ino ||
st.st_dev != curr_dev))
st.st_dev != curr_dev ||
(curr_pos != NULL_POSITION && st.st_size < curr_pos)))
{
/* screen_trashed=2 causes
* make_display to reopen the file. */
Expand Down

0 comments on commit 72d9c93

Please sign in to comment.