-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
net_connections is returning incorrect pid #1013
Comments
Uhm, this is bad. For reference, on FreeBSD global and per-process connections are retrieved differently. The part associating the PID to the connection is here: psutil/psutil/arch/bsd/freebsd_socks.c Line 190 in b940247
|
Mmmm are you sure about this? Can you provide a script to reproduce the issue?
|
OK, I've been lucky and by accident I added a test case which exposes this issue:
So far I've only been able to reproduce it with UNIX sockets ( |
Sorry, since you mentioned |
Yes, AF_INET, could be AF_INET6 as well I have not tried as what I am
working on is currently IPV4 only. Thanks,
Joe
…On Sat, Apr 29, 2017 at 2:31 AM, giampaolo ***@***.***> wrote:
Sorry, since you mentioned status == 'ESTABLISHED' I suppose you see this
also with AF_INET / TCP sockets.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1013 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AD-pHrYSo1s0gjjIrocyQAP2DxeLEZ-2ks5r0udVgaJpZM4NCMK2>
.
|
@glebius is this something you may wanna look at? I'm afraid I don't know how to fix this and it's high priority for FreeBSD users. |
Pull request sent (#1070). |
Thanks a lot @glebius! Your PR fixed the PID mismatch issue which is a big step forward but
In this case the socket not listed is the UNIX socket but I'm not sure if it's relevant.
|
Also (yet another separate issue) I see |
Hey, that was a puzzle for me! Spent 2 hours, while expected 15 minutes issue. So, what is going on here. In What can be done here? Either you need to remove the |
Oh I see. Yes, I agree the function name is confusing as it collides with I don't understand why this is an issue though as both I think the problem is that that specific socket is skipped because we can't determine the PID ( If I put a debugger in
|
Yes, you were right, the non-accepted socket lead me to wrong path. The problem appeared to be set truncation. Pull request sent. |
Thanks. Fixed in #1079. Closing this out. |
On FreeBSD, running psutil.net_connections() is returning connections with incorrect pids.
I tried to match a connection, by status='ESTABLISHED', and laddr= and was given the expected connections, but the pid on one of the processes was reported as another processes pid.
As this was tied to a process timeout program, this gave unexpected and catastrophic results, depending on which process was inserted in place of the pid that should have been reported.
The text was updated successfully, but these errors were encountered: