Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mitmdump random fault while container startup #55

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

LionNatsu
Copy link

@LionNatsu LionNatsu commented Mar 5, 2025

If mitmdump started slow (> T+1s), the process of the async shell task

nohup mitmdump --mode transparent --showhost 2>&1 & echo $! > /tmp/mitmdump.pid

exits too soon (whenever the echo finished).

One second later, the ansible-playbook, which polls every 1s to check whether stdout/process is active, will find the shell process has exited. Subsequently, the stdout/stderr pipes will be closed from the ansible-playbook side, leaving the stdout/stderr fds of the daemonized mitmdump dangling.

When mitmdump finally printed the one-line log message "[HH:mm:ss.xxxx] Transparent Proxy listening at *:8080." to the console, a syscall "write" fails with EPIPE, triggers SIGPIPE and crashes the main program, stops the container, prevents the benchmark from running.

This patch fixes the issue by doing the start-wait-kill trick in one synchronised ansible task.

If mitmdump started slow (> T+1s), the process of the async shell task
```bash
nohup mitmdump --mode transparent --showhost 2>&1 & echo $! > /tmp/mitmdump.pid
```
exits too soon (whenever the echo finished).

One second later, the ansible-playbook, which polls every 1s to check whether stdout/process is active, will find the shell process has exited. Subsequently, the stdout/stderr pipes will be closed from the ansible-playbook side, leaving the stdout/stderr fds of the daemonized mitmdump dangling.

When mitmdump will finally print the one-line log message "[HH:mm:ss.xxxx] Transparent Proxy listening at *:8080." to the console, a syscall "write" fails with EPIPE, triggers SIGPIPE and crashes the main program, stops the container, prevents the benchmark from running.

This patch fixes the issue by doing the start-wait-kill trick in one synchronised ansible task.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant