mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-29 05:03:46 +08:00
job_get_from_pid: don't assume pgid == pid
Compare apples with apples by using getpgid() when checking a process against the job list.
This commit is contained in:
parent
d32e7f5ad7
commit
10e64fd548
|
@ -569,8 +569,21 @@ job_t *parser_t::job_get(job_id_t id) {
|
|||
job_t *parser_t::job_get_from_pid(pid_t pid) {
|
||||
job_iterator_t jobs;
|
||||
job_t *job;
|
||||
|
||||
pid_t pgid = getpgid(pid);
|
||||
|
||||
if (pgid == -1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
while ((job = jobs.next())) {
|
||||
if (job->pgid == pid) return job;
|
||||
if (job->pgid == pgid) {
|
||||
for (const process_ptr_t &p : job->processes) {
|
||||
if (p->pid == pid) {
|
||||
return job;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user