Commit 942bb395 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

startup: don't crash when opening standard input would fail

This fixes https://savannah.gnu.org/bugs/?51206.
parent 52b7a41e
Showing with 9 additions and 3 deletions
+9 -3
...@@ -1145,8 +1145,14 @@ void stdin_pager(void) ...@@ -1145,8 +1145,14 @@ void stdin_pager(void)
/* Open standard input. */ /* Open standard input. */
stream = fopen("/dev/stdin", "rb"); stream = fopen("/dev/stdin", "rb");
if (stream == NULL) if (stream == NULL) {
nperror("fopen"); int errnumber = errno;
terminal_init();
doupdate();
statusline(ALERT, _("Failed to open stdin: %s"), strerror(errnumber));
return;
}
/* Read the input into a new buffer. */ /* Read the input into a new buffer. */
open_buffer("", FALSE); open_buffer("", FALSE);
...@@ -1167,6 +1173,7 @@ void stdin_pager(void) ...@@ -1167,6 +1173,7 @@ void stdin_pager(void)
terminal_init(); terminal_init();
doupdate(); doupdate();
set_modified();
} }
/* Register half a dozen signal handlers. */ /* Register half a dozen signal handlers. */
...@@ -2528,7 +2535,6 @@ int main(int argc, char **argv) ...@@ -2528,7 +2535,6 @@ int main(int argc, char **argv)
/* If one of the arguments is a dash, read text from standard input. */ /* If one of the arguments is a dash, read text from standard input. */
if (optind < argc && !strcmp(argv[optind], "-")) { if (optind < argc && !strcmp(argv[optind], "-")) {
stdin_pager(); stdin_pager();
set_modified();
optind++; optind++;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment