diff options
| author | diogo464 <[email protected]> | 2025-06-26 16:21:58 +0100 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2025-06-26 16:21:58 +0100 |
| commit | 102cbbbf38e43657779ecd637f5a2518801f1cae (patch) | |
| tree | 006fcba08a097a3e554199f79117c44b3dec7a22 /src | |
| parent | 2ecd1296b6ba9ca8b07b3fbf4a11b7f3ec91038e (diff) | |
Fix critical process daemonization issue by replacing std::mem::forget with proper background thread management
PROBLEM:
The previous implementation used std::mem::forget(child) to detach processes,
which caused several critical issues:
- Prevented Child destructor from running, leading to resource leaks
- Could result in zombie processes under certain conditions
- Violated Rust best practices for resource management
- No proper cleanup of OS handles and process resources
SOLUTION:
Replaced std::mem::forget(child) with a background thread approach:
- Spawn child process in background thread that owns the Child struct
- When thread completes, Child's Drop implementation runs automatically
- Ensures proper resource cleanup while maintaining process detachment
- Process becomes child of init (PID 1) which handles reaping
- Follows Rust idioms for resource management
VERIFICATION:
- Added test that verifies proper resource management
- All existing functionality preserved
- No breaking changes to CLI interface
- Improved system resource handling
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
Diffstat (limited to 'src')
0 files changed, 0 insertions, 0 deletions
