Subject: bin/23389: /etc/daily needs lockfile
To: None <gnats-bugs@gnats.netbsd.org>
From: None <wolfgang@wsrcc.com>
List: netbsd-bugs
Date: 11/07/2003 11:10:49
>Number:         23389
>Category:       bin
>Synopsis:       /etc/daily needs lockfile
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 07 19:12:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Wolfgang S. Rupprecht
>Release:        NetBSD 1.6ZE
>Organization:
W S Rupprecht Computer Consulting, Fremont CA
>Environment:
	
	
System: NetBSD capsicum.wsrcc.com 1.6ZE NetBSD 1.6ZE (WSRCC_ATHLON) #6: Mon Nov 3 08:56:59 PST 2003 wolfgang@capsicum.wsrcc.com:/var/obj/netbsd/sys/arch/i386/compile/WSRCC_ATHLON i386
Architecture: i386
Machine: i386
>Description:

	/etc/daily can hang under some circumstances.  (Such as 
	"df" hanging when the server for an imported nfs-filesystem is
	offline.)

	When the stuck nfs server is brought back online all the
	wedged /etc/daily's race it out and trip all over each other.

>How-To-Repeat:
	
	mount some-rarely-used-server:/mnt
	shutdown  some-rarely-used-server
	wait 2 days.
	power up some-rarely-used-server
	watch the fun begin.

>Fix:
	


--- /usr/src/etc/daily	2003-10-01 11:41:46.000000000 -0700
+++ /etc/daily	2003-11-07 11:04:27.000000000 -0800
@@ -11,6 +11,16 @@
 	. /etc/daily.conf
 fi
 
+LOCK=/var/run/root-daily.pid
+
+if [ -f $LOCK ]
+then
+    echo "LOCKED: $LOCK exists"
+else
+    echo "$$" > $LOCK
+
+
+
 host=`hostname`
 date=`date`
 
@@ -252,3 +262,6 @@
 	echo "Running /etc/daily.local:"
 	. /etc/daily.local
 fi
+
+    /bin/rm -f $LOCK
+fi
--- /usr/src/etc/weekly	2001-06-18 03:54:02.000000000 -0700
+++ /etc/weekly	2003-11-07 11:04:20.000000000 -0800
@@ -11,6 +11,14 @@
 	. /etc/weekly.conf
 fi
 
+LOCK=/var/run/root-weekly.pid
+
+if [ -f $LOCK ]
+then
+    echo "LOCKED: $LOCK exists"
+else
+    echo "$$" > $LOCK
+
 host=`hostname`
 date=`date`
 
@@ -78,3 +86,6 @@
 	echo "Running /etc/weekly.local:"
 	. /etc/weekly.local
 fi
+
+    /bin/rm -f $LOCK
+fi
--- /usr/src/etc/monthly	2000-01-10 09:03:49.000000000 -0800
+++ /etc/monthly	2003-11-07 11:04:12.000000000 -0800
@@ -11,6 +11,14 @@
 	. /etc/monthly.conf
 fi
 
+LOCK=/var/run/root-monthly.pid
+
+if [ -f $LOCK ]
+then
+    echo "LOCKED: $LOCK exists"
+else
+    echo "$$" > $LOCK
+
 host=`hostname`
 date=`date`
 
@@ -27,3 +35,6 @@
 	echo "Running /etc/monthly.local:"
 	. /etc/monthly.local
 fi
+
+    /bin/rm -f $LOCK
+fi

>Release-Note:
>Audit-Trail:
>Unformatted: