2

Linuxで作成しているデーモンがあります。init.d ファイルを作成し、使用してデーモン プロセスを正常に開始しました。

/etc/init.d/mydaemon start

ただし、(/etc/init.d/mydaemon stop を使用して) 停止しようとすると、正常に停止しますが、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"
}

これを仮想マシンで実行していますが、何か影響はありますか?

4

1 に答える 1