diff options
author | 2015-11-13 16:48:48 +0000 | |
---|---|---|
committer | 2015-11-13 16:48:48 +0000 | |
commit | a3754e8a13891f1ab1baf6027b6f60748ca1696f (patch) | |
tree | b3ca810b4abf3a002fd345caccb49cc0106faa6a | |
parent | remove skey support (diff) | |
download | wireguard-openbsd-a3754e8a13891f1ab1baf6027b6f60748ca1696f.tar.xz wireguard-openbsd-a3754e8a13891f1ab1baf6027b6f60748ca1696f.zip |
Add a flag argument to flush() to stop it calling quit() on error, then
use this from quit() to stop less blowing up the stack looping through
quit()/flush() if stderr is closed (for example "less /missing
2</dev/null"). ok millert
-rw-r--r-- | usr.bin/less/command.c | 2 | ||||
-rw-r--r-- | usr.bin/less/edit.c | 4 | ||||
-rw-r--r-- | usr.bin/less/funcs.h | 2 | ||||
-rw-r--r-- | usr.bin/less/lsystem.c | 6 | ||||
-rw-r--r-- | usr.bin/less/main.c | 2 | ||||
-rw-r--r-- | usr.bin/less/os.c | 2 | ||||
-rw-r--r-- | usr.bin/less/output.c | 12 | ||||
-rw-r--r-- | usr.bin/less/signal.c | 2 |
8 files changed, 16 insertions, 16 deletions
diff --git a/usr.bin/less/command.c b/usr.bin/less/command.c index d34f2687083..3494a291331 100644 --- a/usr.bin/less/command.c +++ b/usr.bin/less/command.c @@ -81,7 +81,7 @@ cmd_exec(void) { clear_attn(); clear_bot(); - flush(); + flush(0); } /* diff --git a/usr.bin/less/edit.c b/usr.bin/less/edit.c index bda64f62152..1da5d6de217 100644 --- a/usr.bin/less/edit.c +++ b/usr.bin/less/edit.c @@ -347,7 +347,7 @@ err1: } free(qopen_filename); no_display = !any_display; - flush(); + flush(0); any_display = TRUE; if (is_tty) { @@ -626,7 +626,7 @@ cat_file(void) while ((c = ch_forw_get()) != EOI) putchr(c); - flush(); + flush(0); } /* diff --git a/usr.bin/less/funcs.h b/usr.bin/less/funcs.h index 38988a18bfb..09c91cedf5f 100644 --- a/usr.bin/less/funcs.h +++ b/usr.bin/less/funcs.h @@ -230,7 +230,7 @@ extern char *errno_message(char *); extern int percentage(off_t, off_t); extern off_t percent_pos(off_t, int, long); extern void put_line(void); -extern void flush(void); +extern void flush(int); extern int putchr(int); extern void putstr(const char *); extern void get_return(void); diff --git a/usr.bin/less/lsystem.c b/usr.bin/less/lsystem.c index 5ef51389aca..6745b487d7d 100644 --- a/usr.bin/less/lsystem.c +++ b/usr.bin/less/lsystem.c @@ -58,7 +58,7 @@ lsystem(const char *cmd, const char *donemsg) * De-initialize the terminal and take out of raw mode. */ deinit(); - flush(); /* Make sure the deinit chars get out */ + flush(0); /* Make sure the deinit chars get out */ raw_mode(0); /* @@ -117,7 +117,7 @@ lsystem(const char *cmd, const char *donemsg) putstr(" (press RETURN)"); get_return(); (void) putchr('\n'); - flush(); + flush(0); } init(); screen_trashed = 1; @@ -207,7 +207,7 @@ pipe_data(char *cmd, off_t spos, off_t epos) putstr("\n"); deinit(); - flush(); + flush(0); raw_mode(0); init_signals(0); lsignal(SIGPIPE, SIG_IGN); diff --git a/usr.bin/less/main.c b/usr.bin/less/main.c index ff26accda7d..abea6389442 100644 --- a/usr.bin/less/main.c +++ b/usr.bin/less/main.c @@ -388,7 +388,7 @@ quit(int status) if (any_display && is_tty) clear_bot(); deinit(); - flush(); + flush(1); raw_mode(0); exit(status); } diff --git a/usr.bin/less/os.c b/usr.bin/less/os.c index 3bbc75e8559..e10135c2813 100644 --- a/usr.bin/less/os.c +++ b/usr.bin/less/os.c @@ -37,7 +37,7 @@ iread(int fd, unsigned char *buf, unsigned int len) int n; start: - flush(); + flush(0); n = read(fd, buf, len); if (n < 0) { /* diff --git a/usr.bin/less/output.c b/usr.bin/less/output.c index a6807f8dceb..5a683b8fdbf 100644 --- a/usr.bin/less/output.c +++ b/usr.bin/less/output.c @@ -76,7 +76,7 @@ static char *ob = obuf; * overwritten or scrolled away. */ void -flush(void) +flush(int ignore_errors) { int n; int fd; @@ -89,7 +89,7 @@ flush(void) fd = (any_display) ? STDOUT_FILENO : STDERR_FILENO; nwritten = write(fd, obuf, n); if (nwritten != n) { - if (nwritten == -1) + if (nwritten == -1 && !ignore_errors) quit(QUIT_ERROR); screen_trashed = 1; } @@ -111,7 +111,7 @@ putchr(int c) * when we are still one char from the end of obuf. */ if (ob >= &obuf[sizeof (obuf)-1]) - flush(); + flush(0); *ob++ = (char)c; return (c); } @@ -277,7 +277,7 @@ error(const char *fmt, PARG *parg) */ screen_trashed = 1; - flush(); + flush(0); } static char intr_to_abort[] = "... (interrupt to abort)"; @@ -297,7 +297,7 @@ ierror(const char *fmt, PARG *parg) (void) less_printf(fmt, parg); putstr(intr_to_abort); at_exit(); - flush(); + flush(0); need_clr = 1; } @@ -325,7 +325,7 @@ query(const char *fmt, PARG *parg) lower_left(); if (col >= sc_width) screen_trashed = 1; - flush(); + flush(0); return (c); } diff --git a/usr.bin/less/signal.c b/usr.bin/less/signal.c index 6cb329c7785..207cf844988 100644 --- a/usr.bin/less/signal.c +++ b/usr.bin/less/signal.c @@ -107,7 +107,7 @@ psignals(void) lsignal(SIGTTOU, SIG_IGN); clear_bot(); deinit(); - flush(); + flush(0); raw_mode(0); lsignal(SIGTTOU, SIG_DFL); lsignal(SIGTSTP, SIG_DFL); |