mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-19 17:12:45 +08:00
Processes to record topic generations before execution
The sigchld generation expresses the idea that, if we receive a sigchld signal, the generation will be different than when we last recorded it. A process cannot exit before it has launched, so check the generation count before process launch. This is an optimization that reduces failing waitpid calls.
This commit is contained in:
parent
a95bc849c5
commit
ebe2dc2766
|
@ -899,6 +899,7 @@ static bool exec_process_in_job(parser_t &parser, process_t *p, std::shared_ptr<
|
|||
}
|
||||
|
||||
// Execute the process.
|
||||
p->check_generations_before_launch();
|
||||
switch (p->type) {
|
||||
case INTERNAL_FUNCTION:
|
||||
case INTERNAL_BLOCK_NODE: {
|
||||
|
|
|
@ -324,7 +324,11 @@ static void handle_child_status(pid_t pid, int status) {
|
|||
}
|
||||
}
|
||||
|
||||
process_t::process_t() {}
|
||||
process_t::process_t() = default;
|
||||
|
||||
void process_t::check_generations_before_launch() {
|
||||
gens_ = topic_monitor_t::principal().current_generations();
|
||||
}
|
||||
|
||||
job_t::job_t(job_id_t jobid, io_chain_t bio, std::shared_ptr<job_t> parent)
|
||||
: block_io(std::move(bio)),
|
||||
|
|
|
@ -113,6 +113,11 @@ class process_t {
|
|||
|
||||
void set_io_chain(const io_chain_t &chain) { this->process_io_chain = chain; }
|
||||
|
||||
/// Store the current topic generations. That is, right before the process is launched, record
|
||||
/// the generations of all topics; then we can tell which generation values have changed after
|
||||
/// launch. This helps us avoid spurious waitpid calls.
|
||||
void check_generations_before_launch();
|
||||
|
||||
/// Actual command to pass to exec in case of EXTERNAL or INTERNAL_EXEC.
|
||||
wcstring actual_cmd;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user