我有一个在 linux 中创建的守护进程。我创建了 init.d 文件并使用成功启动了守护进程
/etc/init.d/mydaemon start
但是,当我尝试停止它时(使用 /etc/init.d/mydaemon stop),它成功停止,但 start-stop-daemon 似乎永远不会完成,因为在调用 start-stop-守护进程
详细模式显示它停止了进程,并且查看系统监视器,它确实停止了进程。
Stopped mydaemon (pid 13292 13310).
这是我的 init.d 文件的停止功能。
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --name $NAME -v
echo "stopped"#This is never printed and the script never formally gives shell back.
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
return "$RETVAL"
}
我在虚拟机上运行这个,这有什么影响吗?