summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-07-24 02:06:07 +0000
committertjr <tjr@FreeBSD.org>2002-07-24 02:06:07 +0000
commit9c6ea7014edab1af5e2d1d262e39b740fd40312e (patch)
tree944ac64c9147450388579c5d5667cd68f728aeff /bin
parent9ece963548fc032edefe665b4c0831dae7414292 (diff)
downloadFreeBSD-src-9c6ea7014edab1af5e2d1d262e39b740fd40312e.zip
FreeBSD-src-9c6ea7014edab1af5e2d1d262e39b740fd40312e.tar.gz
Avoid calling el_resize() from a signal handler, even though libedit
itself does that if you set EL_SIGNAL. Instead, set a flag and check it before calling el_gets(). This is safer, but slower to respond to changes. Pointed out by: mp
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/input.c7
-rw-r--r--bin/sh/trap.c5
-rw-r--r--bin/sh/trap.h1
3 files changed, 11 insertions, 2 deletions
diff --git a/bin/sh/input.c b/bin/sh/input.c
index 9f8df53..47c7283 100644
--- a/bin/sh/input.c
+++ b/bin/sh/input.c
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
#include "alias.h"
#include "parser.h"
#include "myhistedit.h"
+#include "trap.h"
#define EOF_NLEFT -99 /* value of parsenleft when EOF pushed back */
@@ -178,6 +179,12 @@ preadfd(void)
int nr;
parsenextc = parsefile->buf;
+#ifndef NO_HISTORY
+ if (el != NULL && gotwinch) {
+ gotwinch = 0;
+ el_resize(el);
+ }
+#endif
retry:
#ifndef NO_HISTORY
if (parsefile->fd == 0 && el) {
diff --git a/bin/sh/trap.c b/bin/sh/trap.c
index 2ea182c..f848ee1 100644
--- a/bin/sh/trap.c
+++ b/bin/sh/trap.c
@@ -82,6 +82,7 @@ static char *volatile trap[NSIG]; /* trap handler commands */
static volatile sig_atomic_t gotsig[NSIG];
/* indicates specified signal received */
static int ignore_sigchld; /* Used while handling SIGCHLD traps. */
+volatile sig_atomic_t gotwinch;
static int getsigaction(int, sig_t *);
@@ -249,7 +250,7 @@ setsignal(int signo)
#endif
#ifndef NO_HISTORY
case SIGWINCH:
- if (rootshell && iflag && el != NULL)
+ if (rootshell && iflag)
action = S_CATCH;
break;
#endif
@@ -369,7 +370,7 @@ onsig(int signo)
#ifndef NO_HISTORY
if (signo == SIGWINCH)
- el_resize(el);
+ gotwinch = 1;
#endif
}
diff --git a/bin/sh/trap.h b/bin/sh/trap.h
index d633d7a..5578401 100644
--- a/bin/sh/trap.h
+++ b/bin/sh/trap.h
@@ -39,6 +39,7 @@
extern int pendingsigs;
extern int in_dotrap;
+extern volatile sig_atomic_t gotwinch;
int trapcmd(int, char **);
void clear_traps(void);
OpenPOWER on IntegriCloud