You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: prevent unsafe PID conversion in process termination
Fixed the dangerous PID conversion bug:
- Removed: unwrap_or(0) which could signal PID 0 (all processes)
- Added: Let-else pattern for safe PID conversion
- Added: Warning log when PID exceeds i32::MAX
- Added: Early return false on conversion failure
Enhanced documentation:
- Added # Returns section documenting all three failure modes
- Explicitly mentions the PID > 2,147,483,647 edge case
- Clear explanation of when true vs false is returned
- Consistent documentation across Unix and Windows versions
Added context logging:
- Added debug log in stop_child_with_grace when termination fails
- Includes module name, instance ID, and PID for debugging
- Helps identify which module/instance had termination issues
Added comprehensive unit tests:
- Sending SIGTERM to a valid running process (Unix)
- Handling already-exited processes (returns false)
- Windows behavior (always returns false, no SIGTERM support)
- PID conversion edge cases (u32 to i32)
- Normal PID range conversions
Tests cover all platform-specific behaviors and edge cases
to prevent regressions in process termination logic.
Signed-off-by: bit8shift <timothy.low@acronis.com>
0 commit comments