From 3be4e97d2b1d29a23b7a9998f7a124acd4e29f74 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sat, 22 Apr 2017 21:31:37 +0000 Subject: [PATCH] sh: Simplify setinteractive(). setsignal() does nothing if the signal disposition is already set correctly. --- bin/sh/options.c | 2 +- bin/sh/trap.c | 9 ++------- bin/sh/trap.h | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/bin/sh/options.c b/bin/sh/options.c index 56cc5e7397c8..8b501f2d1b6a 100644 --- a/bin/sh/options.c +++ b/bin/sh/options.c @@ -131,7 +131,7 @@ procargs(int argc, char **argv) void optschanged(void) { - setinteractive(iflag); + setinteractive(); #ifndef NO_HISTORY histedit(); #endif diff --git a/bin/sh/trap.c b/bin/sh/trap.c index d67030d370ac..ba643d3485df 100644 --- a/bin/sh/trap.c +++ b/bin/sh/trap.c @@ -478,19 +478,14 @@ dotrap(void) /* - * Controls whether the shell is interactive or not. + * Controls whether the shell is interactive or not based on iflag. */ void -setinteractive(int on) +setinteractive(void) { - static int is_interactive = -1; - - if (on == is_interactive) - return; setsignal(SIGINT); setsignal(SIGQUIT); setsignal(SIGTERM); - is_interactive = on; } diff --git a/bin/sh/trap.h b/bin/sh/trap.h index 8d6cb09c30ba..b9c43f336141 100644 --- a/bin/sh/trap.h +++ b/bin/sh/trap.h @@ -43,6 +43,6 @@ void ignoresig(int); int issigchldtrapped(void); void onsig(int); void dotrap(void); -void setinteractive(int); +void setinteractive(void); void exitshell(int) __dead2; void exitshell_savedstatus(void) __dead2;