Fix lock file cleanup when user triggers SIGINT through Ctrl-C#137
Conversation
Co-authored-by: paolomainardi <8747+paolomainardi@users.noreply.github.com>
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
When users press Ctrl-C during a sparkdock update process, the lock file
/tmp/sparkdock.lockwas not being properly cleaned up, leading to stale lock files that prevented subsequent runs.Problem
The existing code only trapped the
EXITsignal for lock file cleanup:trap cleanup_lock EXITThis meant that when users interrupted the process with Ctrl-C (SIGINT), the cleanup function wasn't called, leaving stale lock files. Users then had to manually remove the lock file:
Additionally, when stale lock files were detected, the script would exit with an error requiring manual intervention instead of automatically cleaning up and continuing.
Solution
trap cleanup_lock EXIT INT TERMcheck_update_lock()function to automatically remove stale lock files and continue execution:Benefits
The changes are minimal (4 lines modified) and preserve all existing behavior while fixing the lock file cleanup issue.
Fixes #136.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
PR Type
Bug fix
Description
Enhanced signal handling to catch SIGINT and SIGTERM
Improved stale lock file detection and automatic cleanup
Removed manual intervention requirement for stale locks
Fixed lock file cleanup on Ctrl-C interruption
Changes walkthrough 📝
sparkdock.macos
Enhanced signal handling and stale lock cleanupbin/sparkdock.macos