1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-08-13 17:03:46 -04:00

handle_unlock: log error when lock file is missing

Problems due to concurrent running instances of pacman can be difficult
to diagnose.  Log a warning to make it more obvious that that's what
happened, that it's a bad idea, and hopefully encourage people who do
things like removing the lock file to run pacman from an install script
to at least be courteous enough to put it back when they're done.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Andrew Gregory 2014-08-01 14:19:51 -07:00 committed by Allan McRae
parent 03b9bf08ac
commit 0bf4ae726d

View File

@ -125,12 +125,20 @@ int _alpm_handle_unlock(alpm_handle_t *handle)
close(handle->lockfd);
handle->lockfd = -1;
if(unlink(handle->lockfile) && errno != ENOENT) {
_alpm_log(handle, ALPM_LOG_WARNING,
_("could not remove lock file %s\n"), handle->lockfile);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"warning: could not remove lock file %s\n", handle->lockfile);
return -1;
if(unlink(handle->lockfile) != 0) {
if(errno == ENOENT) {
_alpm_log(handle, ALPM_LOG_WARNING,
_("lock file missing %s\n"), handle->lockfile);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"warning: lock file missing %s\n", handle->lockfile);
return 0;
} else {
_alpm_log(handle, ALPM_LOG_WARNING,
_("could not remove lock file %s\n"), handle->lockfile);
alpm_logaction(handle, ALPM_CALLER_PREFIX,
"warning: could not remove lock file %s\n", handle->lockfile);
return -1;
}
}
return 0;
}