This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=99bba12f0de89c12a6ab34cc466e8dc1402b1356

commit 99bba12f0de89c12a6ab34cc466e8dc1402b1356 (HEAD -> main)
Author: Guillem Jover <[email protected]>
AuthorDate: Mon Apr 29 09:55:46 2024 +0200

    libdpkg: Try to print the executable name of the lock contending process
    
    Just printing the PID is not very useful to try to track down the
    contending process as its presence might be momentary and might no
    longer be present when the user tries to look for that specific PID.
    
    Try to get the executable name to give a better hint to what might be
    going wrong.
    
    Closes: #1070027
---
 lib/dpkg/file.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/dpkg/file.c b/lib/dpkg/file.c
index 8b316a38b..f664feb94 100644
--- a/lib/dpkg/file.c
+++ b/lib/dpkg/file.c
@@ -35,6 +35,7 @@
 #include <dpkg/fdio.h>
 #include <dpkg/buffer.h>
 #include <dpkg/file.h>
+#include <dpkg/execname.h>
 
 /**
  * Get the current working directory.
@@ -244,6 +245,7 @@ file_lock(int *lockfd, enum file_lock_flags flags, const 
char *filename,
 
        if (fcntl(*lockfd, lock_cmd, &fl) < 0) {
                const char *warnmsg;
+               char *execname;
 
                if (errno != EACCES && errno != EAGAIN)
                        ohshite(_("unable to lock %s"), desc);
@@ -258,8 +260,11 @@ file_lock(int *lockfd, enum file_lock_flags flags, const 
char *filename,
                        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);
+               execname = dpkg_get_pid_execname(fl.l_pid);
+
+               ohshit(_("%s was locked by %s process with pid %d\n%s"),
+                      desc, execname ? execname : C_("process", "<unknown>"),
+                      fl.l_pid, warnmsg);
        }
 
        push_cleanup(file_unlock_cleanup, ~0, 3, lockfd, filename, desc);

-- 
Dpkg.Org's dpkg

Reply via email to