
This patch fixes two things.

First, sloppy error handling when spawning a sub task.

Second, if the process receives a signal while waiting on the lock
file it will return a "timed out" error after only a little more
than a tenth of a second. This was due to the wait time variable
not being reset after each tenth of a second wait.

diff -Nurp autofs-4.1.4.orig/daemon/spawn.c autofs-4.1.4/daemon/spawn.c
--- autofs-4.1.4.orig/daemon/spawn.c	2005-02-10 20:56:53.000000000 +0800
+++ autofs-4.1.4/daemon/spawn.c	2005-11-01 18:36:35.000000000 +0800
@@ -214,14 +214,15 @@ static int do_spawn(int logpri, int use_
 	sigfillset(&allsignals);
 	sigprocmask(SIG_BLOCK, &allsignals, &oldsig);
 
-	if (pipe(pipefd))
+	if (pipe(pipefd)) {
+		if (use_lock)
+			release_lock();
+		sigprocmask(SIG_SETMASK, &oldsig, NULL);
 		return -1;
+	}
 
 	f = fork();
-	if (f < 0) {
-		sigprocmask(SIG_SETMASK, &oldsig, NULL);
-		return -1;
-	} else if (f == 0) {
+	if (f == 0) {
 		reset_signals();
 		close(pipefd[0]);
 		dup2(pipefd[1], STDOUT_FILENO);
@@ -243,6 +244,8 @@ static int do_spawn(int logpri, int use_
 
 		if (f < 0) {
 			close(pipefd[0]);
+			if (use_lock)
+				release_lock();
 			sigprocmask(SIG_SETMASK, &oldsig, NULL);
 			return -1;
 		}
@@ -287,11 +290,11 @@ static int do_spawn(int logpri, int use_
 		if (waitpid(f, &status, 0) != f)
 			status = -1;	/* waitpid() failed */
 
-		sigprocmask(SIG_SETMASK, &oldsig, NULL);
-
 		if (use_lock)
 			release_lock();
 
+		sigprocmask(SIG_SETMASK, &oldsig, NULL);
+
 		return status;
 	}
 }
diff -Nurp autofs-4.1.4.orig/lib/lock.c autofs-4.1.4/lib/lock.c
--- autofs-4.1.4.orig/lib/lock.c	2005-01-17 23:09:28.000000000 +0800
+++ autofs-4.1.4/lib/lock.c	2005-11-01 20:12:28.000000000 +0800
@@ -208,9 +208,6 @@ void release_lock(void)
  */
 static int wait_for_lockf(const char *lockf)
 {
-	struct timespec t = { 0, WAIT_INTERVAL };
-	struct timespec r;
-	int ts_size = sizeof(struct timespec);
 	int tries = WAIT_TRIES;
 	int status = 0;
 	struct stat st;
@@ -218,10 +215,13 @@ static int wait_for_lockf(const char *lo
 	while (tries-- && !status) {
 		status = stat(lockf, &st);
 		if (!status) {
+			struct timespec t = { 0, WAIT_INTERVAL };
+			struct timespec r;
+
 			while (nanosleep(&t, &r) == -1 && errno == EINTR) {
 				if (got_term)
 					return 0;
-				memcpy(&t, &r, ts_size);
+				memcpy(&t, &r, sizeof(struct timespec));
 			}
 		}
 	}
