--- a/joe/main.c
+++ b/joe/main.c
@@ -755,7 +755,10 @@
 			/* Close stdin, so that if user kills the copying the program feeding stdin sees a SIGPIPE */
 			/* It won't if there are any extra file descriptors open */
 			fclose(stdin);
-			stdin = fopen("/dev/tty", "rb");
+            if (!freopen("/dev/tty", "rb", stdin))
+            {
+                /* This should not fail */
+            }
 		}
 	}
 
