Reply To: Long shutown time

Forum › Forums › New users › New Users and General Questions › Long shutown time › Reply To: Long shutown time

#187113
hughtmccullough
Member

    I have found the line of code that results in the 30s shutdown delay and I can confirm that it has something to do with the DisplayLink driver but I’m not sure how to deal with it.

    I started by looking at the DisplayLink script in /etc/init.d/. this script contains the code

    if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
        set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
    fi

    I then looked at /lib/init/init-d-script and it contains the following code block:

    do_stop_cmd() {
    	start-stop-daemon --stop --quiet \
    	    --retry=TERM/0/CONT/30/KILL/5 \
    	    ${PIDFILE:+--pidfile "$PIDFILE"} \
    	    ${COMMAND_NAME:+--name "$COMMAND_NAME"} \
    	    ${DAEMON:+--exec "$DAEMON"} $STOP_ARGS
    	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.
    	if [ -n "$DAEMON" ] ; then
    		start-stop-daemon --stop --quiet --oknodo \
    		    --retry=0/30/KILL/5 --exec "$DAEMON" $STOP_ARGS
    		[ "$?" = 2 ] && return 2
    	fi
    	# Many daemons don't delete their pidfiles when they exit.
    	rm -f $PIDFILE
    	return $RETVAL
    }

    The line inside the if block:
    start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec "$DAEMON" $STOP_ARGS
    is where the shutdown delay occurs. I inserted some trace statements to see what was going on and when the delay occurred the values were:
    $DAEMON: /opt/displaylink/DisplayLinkManager (which is the DisplayLink driver code)
    $COMMAND_NAME: displaylink
    $PIDFILE: /var/run/displaylink.pid
    $RETVAL: 1
    If I change the number 30 to 120, the shutdown delay increases to two minutes and if I change it to 5, the shutdown delay goes down to just over five seconds.
    The DisplayLink driver functions perfectly from the point of view of providing the functionality of the Lenovo dock that I can plug into the USB port.
    However, am I right that it doesn’t seem to behave properly in the way it presents itself to the operating system?
    Another Daemon that works properly returns the value 0 for $RETVAL.
    I don’t know enough about the inner workings of Linux and SysVinit to know what to do next. I can leave the delay at 5s and it sort of gets round the problem but I am assuming that making changes to a system file like this is a terrible way to deal with the problem.
    Can anyone suggest where I go next?