diff --git a/src/proc.cpp b/src/proc.cpp index a6da0c122..f31b720c4 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -354,10 +354,11 @@ typedef unsigned int process_generation_count_t; static std::vector 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); } }