Fix: when stopping Samba, terminate master smbd process first

This commit is contained in:
Tom Mortensen
2025-11-14 13:42:39 -08:00
parent 068af34ac2
commit 2e21bc3f74

View File

@@ -155,12 +155,17 @@ samba_stop(){
REPLY="Already stopped"
else
REPLY="Stopped"
# stop gracefully with SIGTERM the "master" smbd process first
master=$(ps -o pid=,ppid= -C smbd | awk '$2==1 {print $1}')
[[ -n "master" ]] && run kill "$master"
sleep 1
# stop gracefully with SIGTERM
run killall --ns $$ smbd nmbd wsdd2 winbindd
samba_waitfor_shutdown
if samba_running; then
REPLY="Killed"
# stop forcibly with SIGKILL
[[ -n "master" ]] && run kill -SIGKILL "master"
run killall --ns $$ -SIGKILL smbd nmbd wsdd2 winbindd
samba_waitfor_shutdown
fi