mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-02 21:29:46 +08:00
Fix check for valid disowned pgids
The function `add_disowned_pgid` adds process *group* ids and not process ids. It multiplies the value by negative 1 to indicate a wait on a process group, so the original value must be positive.
This commit is contained in:
parent
4a3ac6e91e
commit
040d921fa1
|
@ -354,10 +354,11 @@ typedef unsigned int process_generation_count_t;
|
||||||
static std::vector<pid_t> s_disowned_pids;
|
static std::vector<pid_t> s_disowned_pids;
|
||||||
|
|
||||||
void add_disowned_pgid(pid_t pgid) {
|
void add_disowned_pgid(pid_t pgid) {
|
||||||
// NEVER add our own pgid, or one of the special values,
|
// NEVER add our own (or an invalid) pgid as they are not unique to only
|
||||||
// or waiting for it will
|
// one job, and may result in a deadlock if we attempt the wait.
|
||||||
// snag other processes away.
|
if (pgid != getpgrp() && pgid > 0) {
|
||||||
if (pgid != getpgrp() && (pgid > 0 || pgid < -1)) {
|
// waitpid(2) is signalled to wait on a process group rather than a
|
||||||
|
// process id by using the negative of its value.
|
||||||
s_disowned_pids.push_back(pgid * -1);
|
s_disowned_pids.push_back(pgid * -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user