mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-20 14:01:12 -03:00
Revert "finish cleanup of signal blocking code"
This reverts commit fb08fe5f47.
Needed to cleanly apply PR#4268. Will reapply after applying that
change.
This commit is contained in:
28
src/exec.cpp
28
src/exec.cpp
@@ -36,6 +36,7 @@
|
||||
#include "postfork.h"
|
||||
#include "proc.h"
|
||||
#include "reader.h"
|
||||
#include "signal.h"
|
||||
#include "wutil.h" // IWYU pragma: keep
|
||||
|
||||
/// File descriptor redirection error message.
|
||||
@@ -321,12 +322,16 @@ 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);
|
||||
@@ -396,8 +401,10 @@ 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.
|
||||
// setup_child_process makes sure signals are properly set up. It will also call
|
||||
// signal_unblock.
|
||||
|
||||
// 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
|
||||
@@ -441,6 +448,8 @@ 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
|
||||
@@ -611,6 +620,9 @@ 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);
|
||||
@@ -618,6 +630,8 @@ 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;
|
||||
@@ -625,7 +639,13 @@ 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) {
|
||||
@@ -775,8 +795,12 @@ 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);
|
||||
@@ -1089,7 +1113,9 @@ 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