Remove get_proc_had_barrier

Prior to this change, fish used a global flag to decide if we should check
for changes to universal variables. This flag was then checked at arbitrary
locations, potentially triggering variable updates and event handlers for
those updates; this was very hard to reason about.

Switch to triggering a universal variable update at a fixed location,
after running an external command.  The common case is that the variable
file has not changed, which we can identify with just a stat() call, so
this is pretty cheap.
This commit is contained in:
ridiculousfish
2019-04-10 16:15:47 -07:00
parent 341799194e
commit a597b0e6e1
5 changed files with 4 additions and 49 deletions

View File

@@ -926,20 +926,6 @@ static bool exec_process_in_job(parser_t &parser, process_t *p, std::shared_ptr<
}
}
// This call is used so the global environment variable array is regenerated, if needed,
// before the fork. That way, we avoid a lot of duplicate work where EVERY child would need
// to generate it, since that result would not get written back to the parent. This call
// could be safely removed, but it would result in slightly lower performance - at least on
// uniprocessor systems.
if (p->type == process_type_t::external) {
// Apply universal barrier so we have the most recent uvar changes
if (!get_proc_had_barrier()) {
set_proc_had_barrier(true);
env_universal_barrier();
}
parser.vars().export_arr();
}
// Execute the process.
p->check_generations_before_launch();
switch (p->type) {