diff --git a/src/files.c b/src/files.c index 20bbd942..a776ff17 100644 --- a/src/files.c +++ b/src/files.c @@ -889,6 +889,8 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable) #endif } +RETSIGTYPE noop(int signal) { } + /* Open the file with the given name. If the file does not exist, display * "New File" if newfie is TRUE, and say "File not found" otherwise. * Return -2 if we say "New File", -1 if the file isn't opened, and the @@ -928,12 +930,21 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f) return -1; } + struct sigaction oldaction, newaction; + if (S_ISFIFO(fileinfo.st_mode)) statusbar(_("Reading from FIFO...")); + newaction.sa_handler = noop; + sigaction(SIGINT, &newaction, &oldaction); + enable_signals(); + /* Try opening the file. */ fd = open(full_filename, O_RDONLY); + disable_signals(); + sigaction(SIGINT, &oldaction, NULL); + if (fd == -1) statusline(ALERT, _("Error reading %s: %s"), filename, strerror(errno)); else { diff --git a/src/proto.h b/src/proto.h index f13e520b..7d121452 100644 --- a/src/proto.h +++ b/src/proto.h @@ -425,6 +425,7 @@ void block_sigwinch(bool blockit); RETSIGTYPE handle_sigwinch(int signal); void regenerate_screen(void); void do_toggle(int flag); +void disable_signals(void); void enable_signals(void); #endif void disable_flow_control(void);