lint: prefer early exits and continue

Fix a location I missed in my earlier cleanup regarding early exits.
This commit is contained in:
Kurtis Rader 2016-11-03 19:42:25 -07:00
parent 87bfd1a01e
commit 98863541c3

View file

@ -318,26 +318,29 @@ static void handle_child_status(pid_t pid, int status) {
} }
} }
if (WIFSIGNALED(status) && (WTERMSIG(status) == SIGINT || WTERMSIG(status) == SIGQUIT)) { // If the child process was not killed by a signal or other than SIGINT or SIGQUIT we're done.
if (!is_interactive_session) { if (!WIFSIGNALED(status) || (WTERMSIG(status) != SIGINT && WTERMSIG(status) != SIGQUIT)) {
struct sigaction act; return;
sigemptyset(&act.sa_mask); }
act.sa_flags = 0;
act.sa_handler = SIG_DFL; if (is_interactive_session) {
sigaction(SIGINT, &act, 0); // In an interactive session, tell the principal parser to skip all blocks we're executing
sigaction(SIGQUIT, &act, 0); // so control-C returns control to the user.
kill(getpid(), WTERMSIG(status)); if (p && found_proc) parser_t::skip_all_blocks();
} else { } else {
// In an interactive session, tell the principal parser to skip all blocks we're // Deliver the SIGINT or SIGQUIT signal to ourself since we're not interactive.
// executing so control-C returns control to the user. struct sigaction act;
if (p && found_proc) { sigemptyset(&act.sa_mask);
parser_t::skip_all_blocks(); act.sa_flags = 0;
} act.sa_handler = SIG_DFL;
} sigaction(SIGINT, &act, 0);
sigaction(SIGQUIT, &act, 0);
kill(getpid(), WTERMSIG(status));
} }
#if 0 #if 0
// TODO: decide whether to eliminate this block or have it emit a warning message. // TODO: Decide whether to eliminate this block or have it emit a warning message.
// WARNING: See the special short-circuit logic above vis-a-vis signals.
if (!found_proc) { if (!found_proc) {
// A child we lost track of? There have been bugs in both subshell handling and in builtin // A child we lost track of? There have been bugs in both subshell handling and in builtin
// handling that have caused this previously... // handling that have caused this previously...