summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog3
-rw-r--r--lib/dpkg/file.c19
2 files changed, 19 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog
index 206c0e6cf..ff6e3cdb5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -16,6 +16,9 @@ dpkg (1.20.0) UNRELEASED; urgency=medium
to specify multiple packages. Closes: #926669
Based on a patch by Frank Schaefer <kelledin@gmail.com>.
* perl: Remove support for versioned GnuPG 2 program and packages.
+ * libdpkg: Clarify lock contender error message. Print the PID of the lock
+ contender, and add a warning explaining that removing the lock file is
+ never the correct solution.
* Perl modules:
- Dpkg::Source::Package: Verify original tarball signatures at build time.
* Documentation:
diff --git a/lib/dpkg/file.c b/lib/dpkg/file.c
index 614d969e3..ceda51047 100644
--- a/lib/dpkg/file.c
+++ b/lib/dpkg/file.c
@@ -189,10 +189,23 @@ file_lock(int *lockfd, enum file_lock_flags flags, const char *filename,
lock_cmd = F_SETLK;
if (fcntl(*lockfd, lock_cmd, &fl) == -1) {
- if (errno == EACCES || errno == EAGAIN)
- ohshit(_("%s is locked by another process"), desc);
- else
+ const char *warnmsg;
+
+ if (errno != EACCES && errno != EAGAIN)
ohshite(_("unable to lock %s"), desc);
+
+ warnmsg = _("Note: removing the lock file is always wrong, "
+ "and can end up damaging the\n"
+ "locked area and the entire system. "
+ "See <https://wiki.debian.org/Teams/Dpkg/FAQ>.");
+
+ file_lock_setup(&fl, F_WRLCK);
+ if (fcntl(*lockfd, F_GETLK, &fl) == -1)
+ ohshit(_("%s was locked by another process\n%s"),
+ desc, warnmsg);
+
+ ohshit(_("%s was locked by another process with pid %d\n%s"),
+ desc, fl.l_pid, warnmsg);
}
push_cleanup(file_unlock_cleanup, ~0, 3, lockfd, filename, desc);