Tinderd Bug - Tinderd killing wrong processes

Tom Judge tom at tomjudge.com
Fri Mar 13 12:08:01 EDT 2009


Joe Marcus Clarke wrote:
> On Thu, 2009-03-12 at 15:23 -0500, Tom Judge wrote:
>   
>> Joe Marcus Clarke wrote:
>>     
>>> On Thu, 2009-03-12 at 14:23 -0500, Tom Judge wrote:
>>>   
>>>   
>>>       
>>>> 2) Why would tinderd think that a jailed processes has a file open in 
>>>> the mount point /data/tinderbox/portstrees/mintel-6-2-mysql-5-0-51 when 
>>>> the jail can't even access that path?
>>>>     
>>>>         
>>> Look at the code in lib/tinderlib.sh for killMountProcesses().  It uses
>>> fstat on the mountpoint to determine what processes need to be killed.
>>>
>>>   
>>>
>>>       
>> Would this not be a more suitable:
>>
>> -------------
>> killMountProcesses () {
>>     dir=$1
>>
>>     pids="XXX"
>>     while [ ! -z "${pids}" ]; do
>>         pids=$(lsof | fgrep "${dir}" | awk '{print $2}' | sort -u)
>>
>>         if [ ! -z "${pids}" ]; then
>>             echo "Killing off pids in ${dir}"
>>             ps -p ${pids}
>>             kill -KILL ${pids} 2> /dev/null
>>             sleep 2
>>         fi
>>     done
>> }
>> -------------
>>
>> Lsof correctly resolves the nullfs layer and prints out information 
>> about the upper nullfs layer, fstat(1) does not seem to be able to do this.
>>     
>
> Speak of the devil.  Okay, cool.  Try this patch, then:
>
> http://www.marcuscom.com/downloads/tinderlib.sh.diff
>
> Joe
>
>   
Hi Joe,

I am currently running with this patch:

itchy# diff -u tinderlib.sh.orig tinderlib.sh
--- tinderlib.sh.orig    2009-02-11 23:55:03.000000000 +0000
+++ tinderlib.sh    2009-03-13 16:04:00.000000000 +0000
@@ -131,7 +131,14 @@
 
     pids="XXX"
     while [ ! -z "${pids}" ]; do
-    pids=$(fstat -f "${dir}" | tail +2 | awk '{print $3}' | sort -u)
+    # Lsof is more reliable when it comes to nullfs, so prefer it if
+    # found.
+    lsof=$(which lsof 2>/dev/null)
+    if [ -n "${lsof}" ]; then
+        pids=$(${lsof} | fgrep "${dir}" | awk '{print $2}' | sort -u)
+    else
+        pids=$(fstat -f "${dir}" | tail +2 | awk '{print $3}' | sort -u)
+    fi
 
     if [ ! -z "${pids}" ]; then
         echo "Killing off pids in ${dir}"
itchy#

Becuase you patch tried to give the FS as an aurgument to lsof which it 
does not support.  I got this using your patch:

itchy# /usr/local/etc/rc.d/tinderbox start
Starting tinderd.
lsof: unknown file struct option: /
lsof: unknown file struct option: d
lsof: unknown file struct option: a
lsof: unknown file struct option: t
lsof: unknown file struct option: a
lsof: unknown file struct option: /
lsof: unknown file struct option: t
lsof: unknown file struct option: i
lsof: unknown file struct option: d
lsof: unknown file struct option: e
lsof: unknown file struct option: r
lsof: unknown file struct option: b
lsof: unknown file struct option: o
lsof: unknown file struct option: x
lsof: unknown file struct option: /
lsof: unknown file struct option: p
lsof: unknown file struct option: o
lsof: unknown file struct option: r
lsof: unknown file struct option: t
lsof: unknown file struct option: s
lsof: unknown file struct option: t
lsof: unknown file struct option: r
lsof: unknown file struct option: e
lsof: unknown file struct option: e
lsof: unknown file struct option: s
lsof: unknown file struct option: /
lsof: unknown file struct option: m
lsof: unknown file struct option: i
lsof: unknown file struct option: t
lsof: unknown file struct option: e
lsof: unknown file struct option: l
lsof: unknown file struct option: -
lsof: unknown file struct option: 7
lsof: unknown file struct option: -
lsof: unknown file struct option: 1
lsof: unknown file struct option: -
lsof: unknown file struct option: m
lsof: unknown file struct option: y
lsof: unknown file struct option: s
lsof: unknown file struct option: q
lsof: unknown file struct option: l
lsof: unknown file struct option: -
lsof: unknown file struct option: 5
lsof: unknown file struct option: -
lsof: unknown file struct option: 0
lsof: unknown file struct option: -
lsof: unknown file struct option: 5
lsof: unknown file struct option: 1
lsof: unknown file struct option: /
lsof: unknown file struct option: p
lsof: unknown file struct option: o
lsof: unknown file struct option: r
lsof: unknown file struct option: t
lsof: unknown file struct option: s
lsof 4.82
 latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/
 latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
 latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man
 usage: [-?abChlnNoOPRtUvV] [+|-c c] [+|-d s] [+|-D D] [+|-f[cfgGn]]
 [-F [f]] [-g [s]] [-i [i]] [-k k] [+|-L [l]] [-m m] [+|-M] [-o [o]] [-p s]
[+|-r [t]] [-s [p:s]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [--] [names]
Use the ``-h'' option to get more help 
information.                                                                                              

itchy# /usr/local/etc/rc.d/tinderbox stop


Regards

Tom


More information about the tinderbox-list mailing list