fix(ip): eliminate zombie sh processes by replacing popen shell with direct subprocess calls#678
Open
fix(ip): eliminate zombie sh processes by replacing popen shell with direct subprocess calls#678
Conversation
…esses Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issue with zombie processes in the system
fix(ip): eliminate zombie sh processes by replacing popen shell with direct subprocess calls
Feb 24, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request eliminates zombie /bin/sh processes that accumulate in Docker containers when crond is used as PID 1. The issue was caused by popen("ip address || ifconfig 2>/dev/null") spawning shell processes for every DNS update cycle, which crond cannot reap as grandchildren.
Changes:
- Replaced
popenshell execution with directsubprocess.check_outputcalls using command arrays - Implemented try-first-then-fallback pattern: attempts
ip addressfirst, falls back toifconfigon failure - Added comprehensive unit tests covering success, fallback, and edge cases
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| ddns/ip.py | Replaced popen with subprocess.check_output in _ip_regex_match, using command arrays instead of shell strings to avoid spawning /bin/sh processes |
| tests/test_ip.py | Added TestIpRegexMatch test class with 5 test cases covering command execution without shell, fallback behavior, and error handling |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_ip_regex_matchusedpopen("ip address || ifconfig 2>/dev/null")which spawns a/bin/shfor every DNS update cycle. In Docker containers withcrondas PID 1, these shells accumulate as zombies since crond doesn't reap grandchildren.Changes
ddns/ip.py: Replacepopenwithsubprocess.check_output— no shell spawned:["ip", "address"]first; fall back to["ifconfig"]onOSError/CalledProcessError["ipconfig"]tests/test_ip.py: AddTestIpRegexMatchcovering:ip addresscalled first withoutshell=True, fallback toifconfigon failure, no-match returnsNone, all-fail returnsNone.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.