1
我有一个我在linux中创建的守护进程。我创建的init.d文件,并已成功地开始使用Linux守护进程停止启动 - 停止守护进程
/etc/init.d/mydaemon start
当我试图阻止它(与/etc/init.d/mydaemon停止)的守护进程,但是,它成功地停止,但开始 - 停止守护进程似乎没有完成,因为在调用启动 - 停止守护进程之后没有立即发生回波,这一点证明了这一点。
详细模式显示它停止进程并查看系统监视器,它确实停止进程。
Stopped mydaemon (pid 13292 13310).
这是我的stop.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"
}
我在虚拟机上运行这个,这会影响任何东西吗?