Send signals in the correct order in hup_jobs()

If the backgrounded/stopped job was using the tty, sending it SIGCONT first
might cause it to immediately wake and try to use the tty (which fish still has
control over), causing it to immediately stop again after receiving a SIGTTOU.

We are supposed to send SIGHUP first so that when the process resumes it sees
the queued SIGHUP and executes its registered handler!
This commit is contained in:
Mahmoud Al-Qudsi 2024-05-30 18:26:13 -05:00
parent e1ee193822
commit 6c944debec

View File

@ -1299,10 +1299,10 @@ pub fn hup_jobs(jobs: &JobList) {
for j in jobs {
let Some(pgid) = j.get_pgid() else { continue };
if pgid != fish_pgrp && !j.is_completed() {
j.signal(SIGHUP);
if j.is_stopped() {
j.signal(SIGCONT);
}
j.signal(SIGHUP);
}
}
}