sh: Simplify setinteractive().

setsignal() does nothing if the signal disposition is already set correctly.
This commit is contained in:
Jilles Tjoelker 2017-04-22 21:31:37 +00:00
parent 6e5e4dbd06
commit 3be4e97d2b
3 changed files with 4 additions and 9 deletions

View File

@ -131,7 +131,7 @@ procargs(int argc, char **argv)
void
optschanged(void)
{
setinteractive(iflag);
setinteractive();
#ifndef NO_HISTORY
histedit();
#endif

View File

@ -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;
}

View File

@ -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;