Fix mitmdump random fault while container startup #55
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.
If mitmdump started slow (> T+1s), the process of the async shell task
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.