start-stop-daemon not removing old pid file

242

Actually start-stop-daemon is not supposed to remove pidfiles. You can do it in your script (rm -f $pidfile). You might want to take a look at some other start script. The script /etc/init.d/dbus for example has the following shutdown script (for do stop):

shut_it_down()
{
  log_daemon_msg "Stopping $DESC" "$NAME"
  start-stop-daemon --stop --retry 5 --quiet --oknodo --pidfile $PIDFILE \
    --user $DAEMONUSER
  # We no longer include these arguments so that start-stop-daemon
  # can do its job even given that we may have been upgraded.
  # We rely on the pidfile being sanely managed
  # --exec $DAEMON -- --system $PARAMS
  log_end_msg $?
  rm -f $PIDFILE
}

From the manual page:

-m, --make-pidfile Used when starting a program that does not create its own pid file. This option will make start-stop-daemon create the file referenced with --pidfile and place the pid into it just before executing the process. Note, the file will not be removed when stopping the program. NOTE: This feature may not work in all cases. Most notably when the program being executed forks from its main process. Because of this, it is usually only useful when combined with the --background option.

(see http://manpages.ubuntu.com/manpages/trusty/man8/start-stop-daemon.8.html)

Share:
242

Related videos on Youtube

Basit Minhas
Author by

Basit Minhas

Updated on September 18, 2022

Comments

  • Basit Minhas
    Basit Minhas over 1 year

    i cannot use previous value using useRef hook. previous value is equal to previous value. can someone tell me why?? and what is the solution.

    i need to compare previous value of post;

    const [selectedPost, setSelectedPost] = useState({ title: "", content: "" });
    

    Following is previous value function

    function usePrevious(value) {
        const ref = useRef();
        useEffect(() => {
          ref.current = value;
        });
        return ref.current;
      }
      const prevVal = usePrevious(selectedPost);
    

    Following is the function in which i use previous value

    const handleClickUpdate = () => {
        if (prevVal === selectedPost && isEmpty(errors))
          return setEditClicked(false);
    
        editPost(selectedPost, postId, "original", () => setEditClicked(false));
      };
    

    Edit//

    i found out its happening because of this block of code. can someone explain why??

    //clear validation errors on typing title or content
      useEffect(() => {
        if (!isEmpty(selectedPost.title) && !isEmpty(selectedPost.content))
          dispatch(saveErrors({}));
      }, [selectedPost, dispatch]);
    
    • Sivaram P
      Sivaram P over 3 years
      This question should be useful.
  • FrustratedWithFormsDesigner
    FrustratedWithFormsDesigner over 8 years
    Thanks, I didn't know it would not remove old PID files. I'll just add the rm -f $PID_FILE.