From e58ad5728ddc1be15c46cfcc79502985d0769b19 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Wed, 22 May 2019 20:33:15 +1000 Subject: [PATCH] Just signal the process if we can't get the process group. On OpenBSD (and possibly others) we can't get the process group of a process that's in a different session, so fall back to signalling the process. --- src/baseproc-service.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/baseproc-service.cc b/src/baseproc-service.cc index b6809c4..a0d4165 100644 --- a/src/baseproc-service.cc +++ b/src/baseproc-service.cc @@ -331,8 +331,13 @@ void base_process_service::kill_pg(int signo) noexcept else { pid_t pgid = bp_sys::getpgid(pid); if (pgid == -1) { - // only should happen if pid is invalid, which should never happen... - log(loglevel_t::ERROR, get_name(), ": can't signal process: ", strerror(errno)); + // On some OSes (eg OpenBSD) we aren't allowed to get the pgid of a process in a different + // session. Just kill the process in that case. + log(loglevel_t::WARN, get_name(), ": can't signal process group: ", strerror(errno)); + log(loglevel_t::WARN, get_name(), ": will signal process only " + "(consider using option = signal-process-only)"); + + bp_sys::kill(pid, signo); return; } bp_sys::kill(-pgid, signo); -- 2.25.1