Hi Kel,

Kel Modderman wrote:
I though I was either crazy, or you were whispering sweet nothings in my ear, because on my boxen sendsigs was still at sequence number 20. Then I found this in /usr/share/doc/initscripts/changelog.Debian.gz:

<blushes> Sorry about that.

Hmm. I think this is no longer wpasupplicant issue, but please do not close that bug, it it's OK with you. My suggestion would be to ask the sysvinit guys to replace sendsigs with the following script (not sure if the attachment will come through, if it does not, I will repost the script body).

Basically, in this script killall5 is replaced by a shell function that does the same and takes command names
as parameters. These command are never killed.

It solves both the wpasupplicant issue and usplash issue (I did not test the latter, I admit).

The following sequence would be needed:
1. new (well, let's call it my) sendsigs would have to be run before umountnfs
2. umountnfs
3. wpasupplicant
4. original sendsigs (or mine running without exceptions).

What would also be needed is you backing this solution, of course ;-)


bye,

Przemek


#! /bin/sh
### BEGIN INIT INFO
# Provides:          sendsigs
# Required-Start:    
# Required-Stop:     umountnfs
# Default-Start:
# Default-Stop:      0 6
# Short-Description: Kill all remaining processes except for crucial ones.
# Description: 
### END INIT INFO

PATH=/usr/sbin:/usr/bin:/sbin:/bin

. /lib/lsb/init-functions

#lists all ancestor pids, until pid number 0 is reached
getAncestorPids() {
        local pid=$1
        local ppids=

        while true; do
                ppid=$(ps --no-headers --format ppid $pid)
                if [ $ppid -eq 0 ]; then
                        break;
                fi
                ppids=$ppid" "$ppids
                pid=$ppid
        done
        echo $ppids
}


# Replacement for killall5 command. Just like killall5 does, it sends
# a signal to all processes except for: ancestor processes, itself
# and kernel threads.
# Addtionally, it skips all processes that had been run using command
# name passed as a parameter.
#
# arguments:
# signalnumber
# list of command names that should not be killed
killall5_except() {
        local signalNumber="$1"
        shift 
        local myPid=$$
        local preciousPids=$(ps --no-headers --format pid -C "$*")
        #initial precious pids are: my pid and pids of processes given as 
parameters
        preciousPids=$myPid" "$preciousPids
        local ancestorPids=

        for preciousPid in $preciousPids; do
                local sessionLeaderPid=$(ps --no-headers --format session 
$preciousPid)
                ancestorPids=$ancestorPids" "$(getAncestorPids $preciousPid)
        done

        #kernel threads should not be killed too. Kernel threads have userspace 
size of 0.
        local kernelThreadPids=$(ps --format pid,size --no-headers -A | grep " 
"0$| sed -e s/" [^ ]*$"//)

        allPreciousPids="$preciousPids $ancestorPids $kernelThreadPids"

        allPidsToTerminate=$(ps --deselect --no-headers --format pid --pid 
$allPreciousPids)
        
        #a trick to eliminate ps pid from the list
        allPidsToTerminate=$(ps --no-headers --format pid --pid 
$allPidsToTerminate)
        
        if [ ! -z "$allPidsToTerminate" ]; then
            kill $signalNumber $allPidsToTerminate
        fi
}

do_stop () {
        # Kill all processes.
        log_action_begin_msg "Asking all remaining processes to terminate"
        killall5_except -15 wpa_supplicant usplash
        log_action_end_msg 0
        sleep 5
        log_action_begin_msg "Killing all remaining processes"
        killall5_except -9 wpa_supplicant usplash
        log_action_end_msg 0
}

case "$1" in
  start)
        # No-op
        ;;
  restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
  stop)
        do_stop
        ;;
  *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac

:

Reply via email to