Ticket #2160: stale-pidfiles.patch

File stale-pidfiles.patch, 2.4 KB (added by dnicholson@…, 17 years ago)

Remove stale pid files when encountered

  • bootscripts/ChangeLog

    commit 77f8dc9597436905f3a59ca942c6ee32c2e05e5f
    Author: Dan Nicholson <dbn.lists@gmail.com>
    Date:   Wed Mar 12 14:04:53 2008 -0700
    
        Remove stale pid files when encountered in loadproc/killproc/reloadproc
    
    diff --git a/bootscripts/ChangeLog b/bootscripts/ChangeLog
    index 2c7273b..f982866 100644
    a b  
     12008-03-12      Dan Nicholson   <dnicholson@linuxfromscratch.org>
     2        * lfs/init.d/functions: Remove stale pid files when encountered
     3          in loadproc/killproc/reloadproc. When the bootscript specifies
     4          a pid file to use with the "-p pidfile" argument, *proc
     5          functions previously bailed out when the referenced file
     6          contains an invalid pid.
     7
    182007-08-20      DJ Lucas <dj@linuxfromscratch.org>
    29        * lfs/init.d/setclock: Added missing 'stop' argument to usage text
    310
  • bootscripts/lfs/init.d/functions

    diff --git a/bootscripts/lfs/init.d/functions b/bootscripts/lfs/init.d/functions
    index a9e13fd..7a0b584 100644
    a b reloadproc()  
    291291                pidofproc -s -p "${pidfile}" "${1}"
    292292        fi
    293293
     294        # Warn about stale pid file
     295        if [ "$?" = 1 ]; then
     296                boot_mesg -n "Removing stale pid file: ${pidfile}. " ${WARNING}
     297                rm -f "${pidfile}"
     298        fi
     299
    294300        if [ -n "${pidlist}" ]; then
    295301                for pid in ${pidlist}
    296302                do
    getpids()  
    504510#                     warning in stdout
    505511#          return 4 - Program or service status is unknown
    506512#
    507 # Dependencies: nice
     513# Dependencies: nice, rm
    508514#
    509515# Todo: LSB says this should be called start_daemon
    510516#       LSB does not say that it should call evaluate_retval
    loadproc()  
    567573                                return 0 # 4
    568574                                ;;
    569575                        1)
    570                                 log_warning_msg "Unable to continue: ${pidfile} exists"
    571                                 return 0 # 4
     576                                boot_mesg "Removing stale pid file: ${pidfile}" ${WARNING}
     577                                rm -f "${pidfile}"
    572578                                ;;
    573579                        3)
    574580                                ;;
    loadproc()  
    598604#                     warning in stdout
    599605#          return 4 - Unknown Status
    600606#
    601 # Dependencies: kill
     607# Dependencies: kill, rm
    602608#
    603609# Todo: LSB does not say that it should call evaluate_retval
    604610#       It checks for PIDFILE, which is deprecated.
    killproc()  
    648654                pidofproc -s -p "${pidfile}" "${1}"
    649655        fi
    650656
     657        # Remove stale pidfile
     658        if [ "$?" = 1 ]; then
     659                boot_mesg "Removing stale pid file: ${pidfile}." ${WARNING}
     660                rm -f "${pidfile}"
     661        fi
     662
    651663    # If running, send the signal
    652664    if [ -n "${pidlist}" ]; then
    653665        for pid in ${pidlist}