diff --git a/ChangeLog b/ChangeLog
index e0b7e18966cd96151061e9ca7e24f5da2442cb12..00ce9cedc5bf808ea6743acca68068297f936354 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -233,6 +233,11 @@ CVS code -
   revstrstr(), revstristr()
 	- Add asserts. (DLR)
 - winio.c:
+  get_buffer()
+	- If we get ERR when using blocking input, it means that the
+	  input source that we were using is gone.  In this case, call
+	  handle_hupterm(), so that nano dies gracefully instead of
+	  going into an infinite loop. (DLR, found by Jim Uhl)
   titlebar()
 	- Rename some variables for consistency, make space an int
 	  instead of a size_t, properly handle the case where the prefix
diff --git a/src/winio.c b/src/winio.c
index f3ed69bb3e7ab4e13be7ad67e330b742cf6238bd..522a79ed869d794c58c99c90fc7dd7e3dfbccd74 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -140,6 +140,11 @@ void get_buffer(WINDOW *win)
 
     input = wgetch(win);
 
+    /* If we get ERR when using blocking input, it means that the input
+     * source that we were using is gone, so die gracefully. */
+    if (input == ERR)
+	handle_hupterm(0);
+
 #ifndef NANO_SMALL
     allow_pending_sigwinch(FALSE);
 #endif