job_signal: confirm process group before signalling it

It is possible for fish to not be the process group leader; avoid
signalling the process group containing the current process by checking
with getpgrp() rather than assuming that getpid() is enough.
This commit is contained in:
David Adam 2017-04-23 22:51:01 +08:00
parent 8f77b1cdd2
commit 16931f724b

View File

@ -244,10 +244,10 @@ void job_t::set_flag(job_flag_t flag, bool set) {
bool job_t::get_flag(job_flag_t flag) const { return !!(this->flags & flag); }
int job_signal(job_t *j, int signal) {
pid_t my_pid = getpid();
pid_t my_pgid = getpgrp();
int res = 0;
if (j->pgid != my_pid) {
if (j->pgid != my_pgid) {
res = killpg(j->pgid, signal);
} else {
for (const process_ptr_t &p : j->processes) {