mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-29 10:31:14 -03:00
event: reduce lock scope to allow re-locking in event handler
The following "Port execution" commit will use RefCell for the wait handle store. If we hold a borrow while we are running an event (which may run script code) there will be a borrowing conflict. Avoid this by returning the borrow earlier.
This commit is contained in:
@@ -356,16 +356,14 @@ pub fn function(
|
||||
for ed in &opts.events {
|
||||
match *ed {
|
||||
EventDescription::ProcessExit { pid } if pid != event::ANY_PID => {
|
||||
if let Some(status) = parser
|
||||
.get_wait_handles()
|
||||
.get_by_pid(pid)
|
||||
.and_then(|wh| wh.status())
|
||||
{
|
||||
let wh = parser.get_wait_handles().get_by_pid(pid);
|
||||
if let Some(status) = wh.and_then(|wh| wh.status()) {
|
||||
event::fire(parser, event::Event::process_exit(pid, status));
|
||||
}
|
||||
}
|
||||
EventDescription::JobExit { pid, .. } if pid != event::ANY_PID => {
|
||||
if let Some(wh) = parser.get_wait_handles().get_by_pid(pid) {
|
||||
let wh = parser.get_wait_handles().get_by_pid(pid);
|
||||
if let Some(wh) = wh {
|
||||
if wh.is_completed() {
|
||||
event::fire(parser, event::Event::job_exit(pid, wh.internal_job_id));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user