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 }