mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-23 08:58: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;
|
||||
|
||||
void add_disowned_pgid(pid_t pgid) {
|
||||
// NEVER add our own pgid, or one of the special values,
|
||||
// or waiting for it will
|
||||
// snag other processes away.
|
||||
if (pgid != getpgrp() && (pgid > 0 || pgid < -1)) {
|
||||
// NEVER add our own (or an invalid) pgid as they are not unique to only
|
||||
// one job, and may result in a deadlock if we attempt the wait.
|
||||
if (pgid != getpgrp() && pgid > 0) {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user