From 68a83a64cd424385b613f58e23c03e262d840b91 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 6 Mar 2020 13:07:55 +0100 Subject: GetLock: No strerror if it's just another process holding the lock This improves the locking message, getting rid of useless details. If we have a process holding the lock, we got that because the lock is being hold by it, so there's no point telling the people the reason for not getting the lock is the EAGAIN error and displaying its strerrror(). --- apt-pkg/contrib/fileutl.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'apt-pkg/contrib/fileutl.cc') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index db5463be2..045dbe17d 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -302,13 +302,15 @@ int GetLock(string File,bool Errors) if (Errors == true) { + // We only do the lookup in the if ((errno == EACCES || errno == EAGAIN)) + // case, so we do not need to show the errno strerrr here... if (fl.l_pid != -1) { auto name = GetProcessName(fl.l_pid); if (name.empty()) - _error->Errno("open", _("Could not get lock %s. It is held by process %d"), File.c_str(), fl.l_pid); + _error->Error(_("Could not get lock %s. It is held by process %d"), File.c_str(), fl.l_pid); else - _error->Errno("open", _("Could not get lock %s. It is held by process %d (%s)"), File.c_str(), fl.l_pid, name.c_str()); + _error->Error(_("Could not get lock %s. It is held by process %d (%s)"), File.c_str(), fl.l_pid, name.c_str()); } else _error->Errno("open", _("Could not get lock %s"), File.c_str()); -- cgit v1.2.3