[pacman-dev,v2] lock file may be left behind when a signal arrives while in cleanup

Message ID 20200812151748.1760219-1-lilydjwg@gmail.com
State New
Headers show
Series
  • [pacman-dev,v2] lock file may be left behind when a signal arrives while in cleanup
Related show

Commit Message

lilydjwg Aug. 12, 2020, 3:17 p.m. UTC
When a SIGINT or SIGHUP arrives before alpm_unlock (in alpm_release) but
after remove_soft_interrupt_handler, the lock file will be left behind.

Signed-off-by: lilydjwg <lilydjwg@gmail.com>
---

Oops, here is an updated version that calls _alpm_handle_unlock
before remove_soft_interrupt_handler. It should be fine to call
_alpm_handle_unlock twice.

 src/pacman/pacman.c | 3 +++
 1 file changed, 3 insertions(+)

Patch

diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index fefd3fa4..8928ccc4 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -287,6 +287,9 @@  static void setuseragent(void)
  */
 static void cleanup(int ret)
 {
+	if(config) {
+		_alpm_handle_unlock(config->handle);
+	}
 	remove_soft_interrupt_handler();
 	if(config) {
 		/* free alpm library resources */