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
Process.GetProcesses returns truncated 15 char string on Linux #28346
When using Process.GetProcesses() in dotnet core it returns the Process.ProcessName property fine under Windows as expected.
However when ran under Linux (Tested on Ubuntu 17.04) it seems to return process names as 15 char long strings. It truncates the process names to all be 15 char long strings.
It looks like /proc/<PID>/exe is one way to get the full file name
dan@danmose3:~/git/corefx/src/Native$ ls -l /proc/10725/exe
lrwxrwxrwx 1 dan dan 0 Jan 8 14:38 /proc/10725/exe -> /home/dan/123456789012345678901234567890
It looks like we already get the full exe path from this file. We just need to use it a few lines higher up (cropping off the path) instead of the stat entry
Have you written a unit test? Take a look at existing tests under Systrm.Diagnostics.Process/tests. There are some that launch processes. You could follow the pattern but rename the file to a long name before launching. Or possibly copy "sleep" to a long name version then run it with a large value, read the name, then terminate it and delete it. This assumes all distros have sleep.
On 2 Feb 2019, 19:17, at 19:17, Dan Moseley ***@***.***> wrote:
Have you written a unit test? Take a look at existing tests under
Systrm.Diagnostics.Process/tests. There are some that launch processes.
You could follow the pattern but rename the file to a long name before
launching. Or possibly copy "sleep" to a long name version then run it
with a large value, read the name, then terminate it and delete it.
This assumes all distros have sleep.
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
https://github.com/dotnet/corefx/issues/34437#issuecomment-459991461
Process name: indicator-application-service
Process name: indicator-session-service
Process name: indicator-messages-service
Process name: indicator-sound-service
Process name: indicator-power-service
Process name: mate-terminal
Process name: bash
Process name: obexd
Process name: bash
Process name: htop
@2E0PGS hello, are you still working on this one? I think only test remains? You could throw up a PR just for work in progress, that others could comment on.
Yes I been busy with work. Probably wouldn't have another chance to look until weekend.
If you need quicker fix then I'll create a PR for someone else to create the test for?
Cheers,
Activity
danmoseley commentedon Jan 8, 2019
Thanks for the pointer to the MacOS bug fix. It seems Linux has a similar limit. Here is a process with a 30 character name, only 15 show:
This is because
/proc/<PID>/statgets the value from task_struct which is TASK_COMM_LEN chars (sched.h) which is 16 including null.danmoseley commentedon Jan 8, 2019
It looks like
/proc/<PID>/exeis one way to get the full file namedanmoseley commentedon Jan 8, 2019
It looks like we already get the full exe path from this file. We just need to use it a few lines higher up (cropping off the path) instead of the stat entry
https://github.com/dotnet/corefx/blob/e0ba7aa8026280ee3571179cc06431baf1dfaaac/src/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Linux.cs#L76-L85
danmoseley commentedon Jan 8, 2019
@2E0PGS any interest in making this change, with a unit test?
2E0PGS commentedon Jan 8, 2019
Thanks for pulling out those lines and doing a few basic tests.
I will have a further look at the code base and check what unit tests are in place at the moment.
I will try give it a shot if I get some free time. Otherwise I will let you know if I am too busy to make the change.
danmoseley commentedon Jan 8, 2019
OK, thanks. As for Mac it seems we do not use /proc/../stat but it would be nice to have a test (need not be you of course)
danmoseley commentedon Feb 2, 2019
@2E0PGS do you think you might give this a go? Let me know if you need pointers getting set up?
2E0PGS commentedon Feb 2, 2019
Sorry been very busy. Yes I was just reading the dotnet core wiki for setting up the development environment. Hopefully I can give it a go soon.
2E0PGS commentedon Feb 2, 2019
I don't quite know know why the solution doesn't pickup the distro specific cs files.
2E0PGS commentedon Feb 2, 2019
Got a build done, just need to see how I am going to run this inplace of regular dotnet core on the system to check it against my test program.
danmoseley commentedon Feb 2, 2019
Have you written a unit test? Take a look at existing tests under Systrm.Diagnostics.Process/tests. There are some that launch processes. You could follow the pattern but rename the file to a long name before launching. Or possibly copy "sleep" to a long name version then run it with a large value, read the name, then terminate it and delete it. This assumes all distros have sleep.
2E0PGS commentedon Feb 2, 2019
2E0PGS commentedon Feb 3, 2019
I got this so far: 2E0PGS/corefx@691e55e
Just need to test this on Linux.
2E0PGS commentedon Feb 3, 2019
OK so implementing those changes: 2E0PGS/corefx@e1e308c
Using my test program the output we had before any of my changes looked like this and it had a name for every process.
Using the recent commit I linked above the test program has quite a few processes without names.
2E0PGS commentedon Feb 3, 2019
However the names are now longer than 15 chars. We need to investigate why some are blank.
6 remaining items
danmoseley commentedon Feb 20, 2019
Was out of office -- @2E0PGS yes, I think so. Try that, plus a test?
2E0PGS commentedon Feb 20, 2019
I will give that a try soon thanks.
2E0PGS commentedon Feb 24, 2019
Just building a new corefx now to test it against a CLI app.
2E0PGS commentedon Feb 24, 2019
Ok this commit works well: 2E0PGS/corefx@56e7385
Test CLI program output:
No missing process names now.
danmoseley commentedon Feb 25, 2019
Great, do you want to create a test and put up a PR?
2E0PGS commentedon Feb 25, 2019
danmoseley commentedon Feb 25, 2019
Thanks @2E0PGS
danmoseley commentedon Mar 5, 2019
@2E0PGS hello, are you still working on this one? I think only test remains? You could throw up a PR just for work in progress, that others could comment on.
2E0PGS commentedon Mar 5, 2019
danmoseley commentedon Mar 5, 2019
@2E0PGS totally fine. It's just us keeping the pipes flowing rather than any particular urgency for this one.