aboutsummaryrefslogtreecommitdiffstats
path: root/lock.c
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2006-07-04 10:01:51 +0000
committerMatthias Andree <matthias.andree@gmx.de>2006-07-04 10:01:51 +0000
commit274eec54e80cb90b8a09f524c8495efbaa46b45d (patch)
tree75db80dfc5c3234e8be9f0bac0ed6f120c55728e /lock.c
parent35a58f784af38c9390158f1285d40c1e53baa884 (diff)
downloadfetchmail-274eec54e80cb90b8a09f524c8495efbaa46b45d.tar.gz
fetchmail-274eec54e80cb90b8a09f524c8495efbaa46b45d.tar.bz2
fetchmail-274eec54e80cb90b8a09f524c8495efbaa46b45d.zip
If the lockfile ends before the process ID, treat it as stale and unlink it.
Reported by Justin Pryzby, Debian Bug #376603. svn path=/branches/BRANCH_6-3/; revision=4862
Diffstat (limited to 'lock.c')
-rw-r--r--lock.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lock.c b/lock.c
index 39351be1..c0290393 100644
--- a/lock.c
+++ b/lock.c
@@ -85,20 +85,21 @@ int fm_lock_state(void)
if (ferror(lockfp)) {
fprintf(stderr, GT_("fetchmail: error reading lockfile \"%s\": %s\n"),
lockfile, strerror(errno));
+ fclose(lockfp); /* not checking should be safe, file mode was "r" */
exit(PS_EXCLUDE);
}
+ fclose(lockfp); /* not checking should be safe, file mode was "r" */
- if (args == 0 || kill(pid, 0) == -1) {
+ if (args == EOF || args == 0 || kill(pid, 0) == -1) {
pid = 0;
+
+ fprintf(stderr,GT_("fetchmail: removing stale lockfile\n"));
if (unlink(lockfile)) {
if (errno != ENOENT) {
perror(lockfile);
}
- } else {
- fprintf(stderr,GT_("fetchmail: removing stale lockfile\n"));
}
}
- fclose(lockfp); /* not checking should be safe, file mode was "r" */
} else {
pid = 0;
if (errno != ENOENT) {