mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-11 22:21:14 -03:00
finish cleanup of signal blocking code
PR #3691 made most calls to `signal_block()` and `signal_unblock()` no-ops unless a magic env var is set when fish starts running. It's been seven months since that change was made and no problems have been reported. This finishes that work by removing those no-op function calls and support for the magic env var in our next major release (which won't happen till at least six months from now).
This commit is contained in:
28
src/exec.cpp
28
src/exec.cpp
@@ -36,7 +36,6 @@
|
||||
#include "postfork.h"
|
||||
#include "proc.h"
|
||||
#include "reader.h"
|
||||
#include "signal.h"
|
||||
#include "wutil.h" // IWYU pragma: keep
|
||||
|
||||
/// File descriptor redirection error message.
|
||||
@@ -322,16 +321,12 @@ static void internal_exec_helper(parser_t &parser, const wcstring &def, node_off
|
||||
return;
|
||||
}
|
||||
|
||||
signal_unblock();
|
||||
|
||||
if (node_offset == NODE_OFFSET_INVALID) {
|
||||
parser.eval(def, morphed_chain, block_type);
|
||||
} else {
|
||||
parser.eval_block_node(node_offset, morphed_chain, block_type);
|
||||
}
|
||||
|
||||
signal_block();
|
||||
|
||||
morphed_chain.clear();
|
||||
io_cleanup_fds(opened_fds);
|
||||
job_reap(0);
|
||||
@@ -399,10 +394,8 @@ void exec_job(parser_t &parser, job_t *j) {
|
||||
|
||||
if (j->processes.front()->type == INTERNAL_EXEC) {
|
||||
// Do a regular launch - but without forking first...
|
||||
signal_block();
|
||||
|
||||
// setup_child_process makes sure signals are properly set up. It will also call
|
||||
// signal_unblock.
|
||||
// setup_child_process makes sure signals are properly set up.
|
||||
|
||||
// PCA This is for handling exec. Passing all_ios here matches what fish 2.0.0 and 1.x did.
|
||||
// It's known to be wrong - for example, it means that redirections bound for subsequent
|
||||
@@ -446,8 +439,6 @@ void exec_job(parser_t &parser, job_t *j) {
|
||||
}
|
||||
}
|
||||
|
||||
signal_block();
|
||||
|
||||
// See if we need to create a group keepalive process. This is a process that we create to make
|
||||
// sure that the process group doesn't die accidentally, and is often needed when a
|
||||
// builtin/block/function is inside a pipeline, since that usually means we have to wait for one
|
||||
@@ -618,9 +609,6 @@ void exec_job(parser_t &parser, job_t *j) {
|
||||
|
||||
switch (p->type) {
|
||||
case INTERNAL_FUNCTION: {
|
||||
// Calls to function_get_definition might need to source a file as a part of
|
||||
// autoloading, hence there must be no blocks.
|
||||
signal_unblock();
|
||||
const wcstring func_name = p->argv0();
|
||||
wcstring def;
|
||||
bool function_exists = function_get_definition(func_name, &def);
|
||||
@@ -628,8 +616,6 @@ void exec_job(parser_t &parser, job_t *j) {
|
||||
const std::map<wcstring, env_var_t> inherit_vars =
|
||||
function_get_inherit_vars(func_name);
|
||||
|
||||
signal_block();
|
||||
|
||||
if (!function_exists) {
|
||||
debug(0, _(L"Unknown function '%ls'"), p->argv0());
|
||||
break;
|
||||
@@ -637,13 +623,7 @@ void exec_job(parser_t &parser, job_t *j) {
|
||||
|
||||
function_block_t *fb =
|
||||
parser.push_block<function_block_t>(p, func_name, shadow_scope);
|
||||
|
||||
// Setting variables might trigger an event handler, hence we need to unblock
|
||||
// signals.
|
||||
signal_unblock();
|
||||
function_prepare_environment(func_name, p->get_argv() + 1, inherit_vars);
|
||||
signal_block();
|
||||
|
||||
parser.forbid_function(func_name);
|
||||
|
||||
if (!p->is_last_in_job) {
|
||||
@@ -794,12 +774,8 @@ void exec_job(parser_t &parser, job_t *j) {
|
||||
const int fg = j->get_flag(JOB_FOREGROUND);
|
||||
j->set_flag(JOB_FOREGROUND, false);
|
||||
|
||||
signal_unblock();
|
||||
|
||||
p->status = builtin_run(parser, p->get_argv(), *builtin_io_streams);
|
||||
|
||||
signal_block();
|
||||
|
||||
// Restore the fg flag, which is temporarily set to false during builtin
|
||||
// execution so as not to confuse some job-handling builtins.
|
||||
j->set_flag(JOB_FOREGROUND, fg);
|
||||
@@ -1108,9 +1084,7 @@ void exec_job(parser_t &parser, job_t *j) {
|
||||
kill(keepalive.pid, SIGKILL);
|
||||
}
|
||||
|
||||
signal_unblock();
|
||||
debug(3, L"Job is constructed");
|
||||
|
||||
j->set_flag(JOB_CONSTRUCTED, true);
|
||||
if (!j->get_flag(JOB_FOREGROUND)) {
|
||||
proc_last_bg_pid = j->pgid;
|
||||
|
||||
Reference in New Issue
Block a user