[Box Backup-commit] COMMIT r2402 - box/trunk/infrastructure

boxbackup-dev@boxbackup.org boxbackup-dev@boxbackup.org
Fri, 5 Dec 2008 23:13:39 +0000 (GMT)


Author: chris
Date: 2008-12-05 23:13:38 +0000 (Fri, 05 Dec 2008)
New Revision: 2402

Modified:
   box/trunk/infrastructure/makebuildenv.pl.in
Log:
Simplify code for killing old fart processes on Windows/Cygwin
and make it actually work at the end of the test. man kill for
why we use /bin/kill instead of just kill on cygwin.


Modified: box/trunk/infrastructure/makebuildenv.pl.in
===================================================================
--- box/trunk/infrastructure/makebuildenv.pl.in	2008-12-05 20:56:00 UTC (rev 2401)
+++ box/trunk/infrastructure/makebuildenv.pl.in	2008-12-05 23:13:38 UTC (rev 2402)
@@ -400,22 +400,35 @@
 				"test script file for $module for writing\n";
 			print TESTFILE "#!/bin/sh\necho TEST: $module\n";
 
-			if (-d "$module/testfiles")
+			if ($target_windows)
 			{
-				if ($target_windows)
-				{
 				print TESTFILE <<__E;
-echo Killing any running daemons...
-test -r testfiles/bbackupd.pid && /bin/kill -f `cat testfiles/bbackupd.pid`
-test -r testfiles/bbstored.pid && /bin/kill -f `cat testfiles/bbstored.pid`
+kill_process()
+{
+	test -r testfiles/$1.pid \
+	&& /bin/kill -0 -f `cat testfiles/$1.pid` \
+	&& /bin/kill    -f `cat testfiles/$1.pid`
+}
 __E
 			}
 			else
 			{
 				print TESTFILE <<__E;
+kill_process()
+{
+	test -r testfiles/$1.pid \
+	&& kill -0 `cat testfiles/$1.pid` \
+	&& kill    `cat testfiles/$1.pid`
+}
+__E
+			}
+
+			if (-d "$module/testfiles")
+			{
+				print TESTFILE <<__E;
 echo Killing any running daemons...
-test -r testfiles/bbackupd.pid && kill `cat testfiles/bbackupd.pid`
-test -r testfiles/bbstored.pid && kill `cat testfiles/bbstored.pid`
+kill_process bbackupd
+kill_process bbstored
 __E
 			}
 
@@ -430,7 +443,7 @@
 __E
 			}
 
-			if(-e "$module/testextra")
+			if (-e "$module/testextra")
 			{
 				open FL,"$module/testextra" or die 
 					"Can't open $module/testextra";
@@ -440,18 +453,12 @@
 
 			print TESTFILE "$runcmd\n";
 
-			if(-d "$module/testfiles")
+			if (-d "$module/testfiles")
 			{
 				print TESTFILE <<__E;
-
-# echo Killing any running daemons...
-test -r testfiles/bbackupd.pid \\
-&& kill -0 `cat testfiles/bbackupd.pid` \\
-&& kill `cat testfiles/bbackupd.pid`
-
-test -r testfiles/bbstored.pid \\
-&& kill -0 `cat testfiles/bbstored.pid` \\
-&& kill `cat testfiles/bbstored.pid`
+echo Killing any running daemons...
+kill_process bbackupd
+kill_process bbstored
 __E
 			}