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"
}
我在虛擬機上運行這個,這會影響任何東西嗎?