From 16931f724b7c2e16aaee6095cfb3e0d65e37f616 Mon Sep 17 00:00:00 2001 From: David Adam Date: Sun, 23 Apr 2017 22:51:01 +0800 Subject: [PATCH] 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. --- src/proc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/proc.cpp b/src/proc.cpp index a1fdab890..3c1327329 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -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) {