Skip to content

Fix Linux local mode missing traffic from non-main threads#314

Open
samatar26 wants to merge 1 commit into
mitmproxy:mainfrom
samatar26:fix-linux-tid-bug
Open

Fix Linux local mode missing traffic from non-main threads#314
samatar26 wants to merge 1 commit into
mitmproxy:mainfrom
samatar26:fix-linux-tid-bug

Conversation

@samatar26

@samatar26 samatar26 commented Jun 11, 2026

Copy link
Copy Markdown

Fixes mitmproxy/mitmproxy#8282

ctx.pid() is the thread id, not the process id so sockets from non-main
threads bypassed Linux local capture. Changed to ctx.tgid(), matching macOS/Windows.

@jackyzy823

jackyzy823 commented Jun 12, 2026

Copy link
Copy Markdown

Passing-by comment:
I found this issue too , but not sure if i understand pid/tgid correct or not.
Then i found that you have already opened a PR !

so user side 's PID is actually kernel side TGID.
Ref:
https://stackoverflow.com/questions/9305992/if-threads-share-the-same-pid-how-can-they-be-identified

@samatar26

Copy link
Copy Markdown
Author

@jackyzy823 yeah exactly - and the behaviour in Linux of mitmproxy is different from macOS and Windows so I believe it must be a bug. Mocking traffic of a python program that's making requests from multiple threads works fine on my macOS machine, but fails on a Linux based GitHub action runner

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.

Linux local mode misses traffic from non-main threads (matches thread id/tid, not process id/tgid)

2 participants