You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Diagnostics.Process on OSX should try harder to provide ProcessName #30909
It seems like the ProcessName should be more than an empty string. On OSX this is pretty egregious as the first couple 100 processes don't have a name. Providing the path to the executable could be a very reasonable fallback. (or perhaps pbi_name has this already?)
I know that proc id 0 is the exception to this rule, but still ProcessName should be useful.
It seems like you've generated the interop for libproc from really old headers. You need to sudo to get all the task info, and the proc_bsdshortinfo struct (which is what you can fill as low-priv) doesn't seem to be generated.
@the-exodus I'm not sure what you mean by we are generating interop from old headers. Can you please explain it more? There is no related native code in corefx there is pinvoke only. Are you referring to managed constants and structs definition?
I tested native proc_pidinfo and proc_name. Both behave the same on the system pids. It requires sudo to be able to obtain the process info.
The proc_name uses proc_pidinfo under the hood and the app should have admin privileges to be able to obtain system process information.
So far the current behavior looks good for me as it respects the OS. The fallback to the path should be implemented on a different layer as a path is not the name.
@the-exodus I'm not sure what you mean by we are generating interop from old headers. Can you please explain it more? There is no related native code in corefx there is pinvoke only. Are you referring to managed constants and structs definition?
Sorry, I totally failed at English there. Anyway, I assumed you had generated the type definitions etc from the header files. The proc_bsdshortinfo type was added a few years ago, and since I didn't see it in the corefx-code I assumed you had been using older headers.
The bsdshortinfo doesn't have name, stats, etc, as you can't query that info for other user's processes. It has everything you CAN get though, which is better than the nullref you get after getting access denied :)
in method name it calls proc_name which return truncated proc name (31char+null terminating). For PID<100 return empty name unless it runs as sudo
in method taskallinfo it calls proc_pidinfo with PROC_PIDTASKALLINFO arg which return truncated proc name (15char+null terminating). For PID<100 return invalid structure unless it runs as sudo
in method bsdshortinfo it calls proc_pidinfo with PROC_PIDT_SHORTBSDINFO arg which return truncated proc name (15char+null terminating). For PID<100 works without sudo
in method bsdinfo it calls proc_pidinfo with PROC_PIDTBSDINFO arg which return truncated proc name (15char+null terminating). For PID<100 return invalid structure unless it runs as sudo
in method pathPart it returns process executable. It works for all cases and without truncating
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.
This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.
Activity
danmoseley commentedon Sep 23, 2019
Thanks for the report. Any interest in proposing a PR?
wfurt commentedon Oct 1, 2019
I did quick check and the output is lame as @JamesWTruher mentioned. It seems like we are failing on
So the problem seems to live deeper in Interop/libproc.
cc: @aik-jahoda
the-exodus commentedon Nov 15, 2019
It seems like you've generated the interop for libproc from really old headers. You need to sudo to get all the task info, and the proc_bsdshortinfo struct (which is what you can fill as low-priv) doesn't seem to be generated.
aik-jahoda commentedon Nov 15, 2019
@the-exodus I'm not sure what you mean by we are generating interop from old headers. Can you please explain it more? There is no related native code in corefx there is pinvoke only. Are you referring to managed constants and structs definition?
aik-jahoda commentedon Nov 15, 2019
I tested native
proc_pidinfoandproc_name. Both behave the same on the system pids. It requires sudo to be able to obtain the process info.The
proc_nameusesproc_pidinfounder the hood and the app should have admin privileges to be able to obtain system process information.So far the current behavior looks good for me as it respects the OS. The fallback to the path should be implemented on a different layer as a path is not the name.
the-exodus commentedon Nov 15, 2019
Sorry, I totally failed at English there. Anyway, I assumed you had generated the type definitions etc from the header files. The proc_bsdshortinfo type was added a few years ago, and since I didn't see it in the corefx-code I assumed you had been using older headers.
The bsdshortinfo doesn't have name, stats, etc, as you can't query that info for other user's processes. It has everything you CAN get though, which is better than the nullref you get after getting access denied :)
aik-jahoda commentedon Nov 18, 2019
@the-exodus the bsdshortinfo works fine. Thank you for pointing to this API.
danmoseley commentedon Jul 8, 2020
@aik-jahoda sounds like you have a sketch of a fix?
aik-jahoda commentedon Jul 8, 2020
I did a c example which demonstrate the functionality. We need to implement C# interop on our side.
danmoseley commentedon Jul 8, 2020
Perhaps you could paste that in here and maybe a member of the community would be interested in doing it.
aik-jahoda commentedon Jul 9, 2020
Attached is example c program:
procinfo.zip
There is several way how to obtain proc name:
nameit calls proc_name which return truncated proc name (31char+null terminating). For PID<100 return empty name unless it runs as sudotaskallinfoit calls proc_pidinfo with PROC_PIDTASKALLINFO arg which return truncated proc name (15char+null terminating). For PID<100 return invalid structure unless it runs as sudobsdshortinfoit calls proc_pidinfo with PROC_PIDT_SHORTBSDINFO arg which return truncated proc name (15char+null terminating). For PID<100 works without sudobsdinfoit calls proc_pidinfo with PROC_PIDTBSDINFO arg which return truncated proc name (15char+null terminating). For PID<100 return invalid structure unless it runs as sudopathPartit returns process executable. It works for all cases and without truncatingdanmoseley commentedon Jul 9, 2020
Pasting here so it's searchable
dotnet-policy-service commentedon Jan 8, 2025
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.
This process is part of our issue cleanup automation.
dotnet-policy-service commentedon Jan 23, 2025
This issue will now be closed since it had been marked
no-recent-activitybut received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.