From 45da6b1ef9a73d8bd6f78719c015a8ee1bd0ee91 Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 2 May 2014 14:15:25 +0800 Subject: [PATCH] refine srs script, use SIGKILL if SIGERM failed. --- trunk/etc/init.d/srs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/trunk/etc/init.d/srs b/trunk/etc/init.d/srs index ab8c62c3a..5c72f9bdc 100755 --- a/trunk/etc/init.d/srs +++ b/trunk/etc/init.d/srs @@ -108,21 +108,32 @@ stop() { ok_msg "Stopping SRS(pid ${srs_pid})..." - # process exists, kill util stop - for((;;)); do + # process exists, try to kill to stop normally + for((i=0;i<30;i++)); do load_process_info if [[ 0 -eq $? ]]; then kill -s SIGTERM ${srs_pid} 2>/dev/null ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "send signal SIGTERM failed ret=$ret"; return $ret; fi sleep 0.1 else - ok_msg "SRS stopped" + ok_msg "SRS stopped by SIGTERM" # delete the pid file when stop success. rm -f ${pid_file} break; fi done + # process exists, use kill -9 to force to exit + load_process_info + if [[ 0 -eq $? ]]; then + kill -s SIGKILL ${srs_pid} 2>/dev/null + ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "send signal SIGKILL failed ret=$ret"; return $ret; fi + ok_msg "SRS stopped by SIGKILL" + else + # delete the pid file when stop success. + rm -f ${pid_file} + fi + sleep 0.1 return 0 }