changeset 7065:04e048fcd6d7 HEAD

If dotlock file contains pid <= 0, assume it's invalid.
author Timo Sirainen <tss@iki.fi>
date Sat, 29 Dec 2007 18:59:34 +0200
parents 046d06f52aa6
children 048325df1ec4
files src/lib/file-dotlock.c
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/file-dotlock.c	Sat Dec 29 18:45:11 2007 +0200
+++ b/src/lib/file-dotlock.c	Sat Dec 29 18:59:34 2007 +0200
@@ -88,6 +88,7 @@
 	char buf[512], *host;
 	int fd;
 	ssize_t ret;
+	pid_t pid;
 
 	fd = open(lock_path, O_RDONLY);
 	if (fd == -1)
@@ -116,7 +117,10 @@
 
 	if (!is_numeric(buf, '\0'))
 		return -1;
-	return (pid_t)strtoul(buf, NULL, 0);
+	pid = (pid_t)strtoul(buf, NULL, 0);
+	if (pid <= 0)
+		return -1;
+	return pid;
 }
 
 static bool