git: b4671758afd7 - main - security/crowdsec: v1.6.3_2 with improved process handling

From: Philippe Audeoud <jadawin_at_FreeBSD.org>
Date: Tue, 08 Oct 2024 07:05:55 UTC
The branch main has been updated by jadawin:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b4671758afd7a15a22d5e9dcdb25b61134d18316

commit b4671758afd7a15a22d5e9dcdb25b61134d18316
Author:     marco <marco@crowdsec.net>
AuthorDate: 2024-10-07 14:03:59 +0000
Commit:     Philippe Audeoud <jadawin@FreeBSD.org>
CommitDate: 2024-10-08 06:03:37 +0000

    security/crowdsec: v1.6.3_2 with improved process handling
    
    PR:             281926
---
 security/crowdsec/Makefile          | 2 +-
 security/crowdsec/files/crowdsec.in | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/security/crowdsec/Makefile b/security/crowdsec/Makefile
index 48f864e77d2a..641c97f30adf 100644
--- a/security/crowdsec/Makefile
+++ b/security/crowdsec/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	crowdsec
 DISTVERSIONPREFIX=	v
 DISTVERSION=	1.6.3
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	security
 
 MAINTAINER=	marco@crowdsec.net
diff --git a/security/crowdsec/files/crowdsec.in b/security/crowdsec/files/crowdsec.in
index 5e827add0062..9952ad5c4974 100644
--- a/security/crowdsec/files/crowdsec.in
+++ b/security/crowdsec/files/crowdsec.in
@@ -52,14 +52,23 @@ crowdsec_stop_precmd() {
     if [ -r "$pidfile_crowdsec" ]; then
         _CROWDSECPID="$(check_pidfile "$pidfile_crowdsec" "$command_crowdsec")"
         export _CROWDSECPID
+        # notification plugins
+        _CROWDSEC_CHILDREN="$(pgrep -P "$_CROWDSECPID")"
+        export _CROWDSEC_CHILDREN
     fi
 }
 
 crowdsec_stop_postcmd() {
+    # don't trust sbin/daemon to send the signal
+    kill -TERM "$_CROWDSECPID" 2>/dev/null
     # wait for process to exit before restarting, or it will find the http port in use
     if [ -n "$_CROWDSECPID" ]; then
         wait_for_pids "$_CROWDSECPID"
     fi
+    if [ -n "$_CROWDSEC_CHILDREN" ]; then
+        kill -TERM $_CROWDSEC_CHILDREN 2>/dev/null
+        wait_for_pids $_CROWDSEC_CHILDREN
+    fi
 }
 
 crowdsec_precmd() {