Skip to content

lvmdbusd: fix deadlock on SIGINT in lvm shell mode

Fix race condition where signal handler could deadlock waiting for shell_lock while worker thread waits for cfg.run.value to be set.

The deadlock scenario:

  1. Worker thread T1 holds shell_lock, waiting in select() (0.5s timeout)
  2. Signal handler receives SIGINT, calls exit_shell()
  3. exit_shell() blocks trying to acquire shell_lock (held by T1)
  4. Signal handler never reaches cfg.run.value = 0 (blocked at step 3)
  5. T1 wakes from select(), checks cfg.run.value != 0 (still true!)
  6. T1 goes back to select(), repeating until test timeout

Solution: Set cfg.run.value = 0 BEFORE calling exit_shell(). This allows worker threads to detect shutdown even if the signal handler blocks on shell_lock, breaking the deadlock.

This fixes occasional test_z_sigint failures in lvm shell mode where the daemon fails to exit within 10 seconds after receiving SIGINT.

Co-Authored-By: Claude noreply@anthropic.com

Merge request reports

Loading