commit d57994fcc3a0339060541069b0b3b2d88a5e2fdb
parent 86fc6e67a81bb671d034c3edcea80eeb0129d4c9
Author: boyska <piuttosto@logorroici.org>
Date:   Thu,  2 Feb 2012 00:31:44 +0100
FIX (tries) #77: slam wasn't slamming
That's because fuser behaves differently on debian.
(Why, debian, why???)
Diffstat:
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -28,3 +28,4 @@ tags
 doc/web/public
 doc/web/dyne
 share/gtkrc
+.*.sw?
diff --git a/src/tomb b/src/tomb
@@ -949,9 +949,25 @@ mount_tomb() {
 # Kill all processes using the tomb
 slam_tomb() {
     # $1 = tomb mount point
-    for s in INT TERM HUP KILL; do
-	fuser -s -m "$1" || return 0
-	fuser -s -m "$1" -k -M -$s && { option_is_set -f || sleep 3 }
+    if [[ -z `fuser -m "$1" 2> /dev/null` ]]; then
+        return 0
+    fi
+    #Note: shells are NOT killed by INT or TERM, but they are killed by HUP
+    for s in TERM HUP KILL; do
+        xxx "Sending $s to processes inside the tomb:"
+        if option_is_set -D; then
+            ps -fp `fuser -m /media/a.tomb 2> /dev/null`|
+            while read line; do
+                xxx $line
+            done
+        fi
+        fuser -s -m "$1" -k -M -$s
+        if [[ -z `fuser -m "$1" 2> /dev/null` ]]; then
+            return 0
+        fi
+        if ! option_is_set -f; then
+            sleep 3
+        fi
     done
     return 1
 }
@@ -1030,8 +1046,7 @@ umount_tomb() {
     if [ $SLAM ]; then
 	_success "Slamming tomb $tombname mounted on $tombmount"
 	_message "Kill all processes busy inside the tomb"
-        slam_tomb "$tombmount"
-        if [[ $? == 1 ]]; then
+        if ! slam_tomb "$tombmount"; then
             _warning "Cannot slam the tomb $tombname"
             return 1
         fi