Skip to content

Enhance Process Identification to Fix PID Recycling Issue#11

Merged
matt-edmondson merged 23 commits into
mainfrom
fix-pid-recycling
Apr 19, 2025
Merged

Enhance Process Identification to Fix PID Recycling Issue#11
matt-edmondson merged 23 commits into
mainfrom
fix-pid-recycling

Conversation

@matt-edmondson
Copy link
Copy Markdown
Contributor

This PR addresses issue #10 by implementing enhanced process identification that goes beyond just checking PIDs.

Key Improvements

1. Enhanced Process Detection

  • Now storing and verifying multiple process attributes (PID, name, start time, file path) to accurately identify processes
  • This prevents false detection when PIDs are recycled after system restarts

2. Improved Storage Format

  • Using JSON serialization for storing detailed process information in PID files
  • Added a ProcessInfo class to maintain structured data about running processes

3. Backward Compatibility

  • Maintained compatibility with older versions that only stored PIDs
  • Added fallback logic to handle legacy PID file formats

4. Robust Error Handling

  • Added comprehensive error handling for various edge cases
  • Improved handling of access restrictions when querying process information

5. Test Improvements

  • Added comprehensive tests for the new functionality
  • Configured tests to run sequentially to avoid file access conflicts
  • Added DoNotParallelize attribute and set MaxCpuCount=1 in .runsettings

6. Documentation Updates

  • Enhanced README with detailed technical information
  • Reorganized Copilot instructions into a modular documentation system

These changes ensure that the SingleAppInstance library can correctly identify whether a process with a given PID is actually the same application or a different one that received a recycled PID after system restart.

Fixes #10

…l implementation details for SingleAppInstance
…est methods, ensuring accurate PID file handling and process information validation.
…n memory usage, coding standards, and project management practices.
…emove unnecessary try-finally blocks, ensuring clearer test flow and improved readability.
Added a `TestInitialize` method to ensure the PID directory exists and the PID file is deleted before each test. Removed redundant PID file deletion from individual test methods to improve code cleanliness and maintainability.
Modified the `dotnet test` command in the `Test` step to include the `-m:1` option. This change aims to improve test execution consistency and optimize resource management during the testing phase.
@matt-edmondson matt-edmondson merged commit 378a833 into main Apr 19, 2025
2 checks passed
@github-project-automation github-project-automation Bot moved this to Done in ktsu.dev Apr 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

If the app doesnt do a clean shutdown and then the machine is restarted the saved PID could be in use by a different app

1 participant