Skip to content

Commit 62a55b9

Browse files
authored
Merge pull request #2461 from unraid/samba-stop
Fix: when stopping Samba, terminate master smbd process first
2 parents ea4b780 + 2e21bc3 commit 62a55b9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

etc/rc.d/rc.samba

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,17 @@ samba_stop(){
155155
REPLY="Already stopped"
156156
else
157157
REPLY="Stopped"
158+
# stop gracefully with SIGTERM the "master" smbd process first
159+
master=$(ps -o pid=,ppid= -C smbd | awk '$2==1 {print $1}')
160+
[[ -n "master" ]] && run kill "$master"
161+
sleep 1
158162
# stop gracefully with SIGTERM
159163
run killall --ns $$ smbd nmbd wsdd2 winbindd
160164
samba_waitfor_shutdown
161165
if samba_running; then
162166
REPLY="Killed"
163167
# stop forcibly with SIGKILL
168+
[[ -n "master" ]] && run kill -SIGKILL "master"
164169
run killall --ns $$ -SIGKILL smbd nmbd wsdd2 winbindd
165170
samba_waitfor_shutdown
166171
fi

0 commit comments

Comments
 (0)