remove unnecessary signal management

The shell was doing a log of signal blocking/unblocking that hurts
performance and can be avoided. This reduced the elapsed time for a
simple benchmark by 25%.

Partial fix for #2007
This commit is contained in:
Kurtis Rader
2016-12-28 18:52:33 -08:00
parent 51adf815aa
commit fd6d814ea4
8 changed files with 113 additions and 85 deletions

View File

@@ -792,19 +792,32 @@ static void read_try(job_t *j) {
/// \param cont If this variable is set, we are giving back control to a job that has previously
/// been stopped. In that case, we need to set the terminal attributes to those saved in the job.
static bool terminal_give_to_job(job_t *j, int cont) {
if (tcsetpgrp(STDIN_FILENO, j->pgid) == -1) {
int result = -1;
errno = EINTR;
while (result == -1 && errno == EINTR) {
result = tcsetpgrp(STDIN_FILENO, j->pgid);
}
if (result == -1) {
if (errno == ENOTTY) redirect_tty_output();
debug(1, _(L"Could not send job %d ('%ls') to foreground"), j->job_id, j->command_wcstr());
wperror(L"tcsetpgrp");
return false;
}
if (cont && tcsetattr(STDIN_FILENO, TCSADRAIN, &j->tmodes)) {
if (cont) {
int result = -1;
errno = EINTR;
while (result == -1 && errno == EINTR) {
result = tcsetattr(STDIN_FILENO, TCSADRAIN, &j->tmodes);
}
if (result == -1) {
if (errno == ENOTTY) redirect_tty_output();
debug(1, _(L"Could not send job %d ('%ls') to foreground"), j->job_id, j->command_wcstr());
debug(1, _(L"terminal_give_to_job(): Could not send job %d ('%ls') to foreground"), j->job_id, j->command_wcstr());
wperror(L"tcsetattr");
return false;
}
}
return true;
}