This patch implements the fix that I mentioned in the comments of bug Menu disappears too quickly - ID: 2985792. It does two things:
- If the menu does not include the system menu, then do not periodically check the menu directory for updates
- If the menu is open and a change is detected that requires rebuilding the menu, then install a signal handler to rebuild the menu after the menu is closed rather than doing so immediately.
This stops the menu from closing unexpectedly on me.