-
Notifications
You must be signed in to change notification settings - Fork 5.1k
SunOS process and thread support #105403
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
base: main
Are you sure you want to change the base?
SunOS process and thread support #105403
Conversation
Lets drop the changes which are already submitted in other PRs. |
src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFsStat.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessThread.SunOS.cs
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.BSD.cs
Outdated
Show resolved
Hide resolved
Good start! I've left initial feedback, which I anticipate the maintainers will point out. :) |
Thanks. I had not yet seen #105207 when I opened this. I think @AustinWise and I should figure out how to get the prerequisite fixes shown there (and here) all integrated, and then I'll rebase the last parts of this onto that. |
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.SunOS.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.SunOS.cs
Outdated
Show resolved
Hide resolved
I'd love to, but I do not see a way to do "stacked" PRs, where one PR targets the branch of another PR. |
Create a local branch |
I'm happy to convert all the prerequisite commits to pull requests, though that will mean this one will fail to build again until those are merged. Is that what we want? |
You can keep this PR and open another PR with |
[StructLayout(LayoutKind.Sequential)] | ||
internal unsafe struct @lwpsinfo | ||
{ | ||
private int pr_flag; /* lwp flags (DEPRECATED; do not use) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the license on the file that this was copied from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://illumos.org/license/CDDL
https://en.wikipedia.org/wiki/Common_Development_and_Distribution_License#Terms suggests source (not binary) should maintain a copy of the license. We can add it to https://github.com/dotnet/runtime/blob/main/THIRD-PARTY-NOTICES.TXT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/sys/procfs.h
It's a published interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea it's fine. Struct definitions and constants usually don't trigger license restrictions. We are doing the same in linux interop code and CDDL is less restrictive than GPL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We prefer to err on the side of doing more attribution.
This is more than 100 lines copied nearly verbatim, including docs. I think it is above the threshold.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, should I just copy the top matter from the illumos procfs.h header?
Or what should the updated top matter look like? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, the ideas (and maybe some code) were borrowed from the following files under src/libraries/Common/src/Interop/
OSX/Interop.libproc.GetProcessInfoById.cs
Linux/procfs/Interop.ProcFsStat.TryReadStatusFile.cs
I've tried to follow what other platform files looked like.
I don't see an example of an attribution to copy.
The OSX code is the closest, if that helps.
Would something like this suffice?
diff --git a/src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFs.Definitions.cs b/src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFs.Definitions.cs
index 7e7a98bda7c..ec65abb5ee9 100644
--- a/src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFs.Definitions.cs
+++ b/src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFs.Definitions.cs
@@ -6,7 +6,8 @@
// C# equivalents for <sys/procfs.h> structures. See: struct lwpsinfo, struct psinfo.
// We read directly onto these from procfs, so the layouts and sizes of these structures
-// must _exactly_ match those in <sys/procfs.h>
+// must _exactly_ match those in the illumos <sys/procfs.h> header. The original is:
+// https://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/sys/procfs.h
// analyzer incorrectly flags fixed buffer length const
// (https://github.com/dotnet/roslyn/issues/37593)
The copied (really derived) parts are the two structs:
internal unsafe struct @lwpsinfo { ... 23 members... }
internal unsafe struct @psinfo { ... 36 members... }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also consider going back to using (a pair of) SystemNative_... functions, one each to read the lwpsinfo and psinfo, which has the advantage that those can be simply C code that uses the actual system header for these (and converts to C# form).
There are pros and cons both ways. I kinda like what's here now, but I'd be open to trying it the other way if reviewers like that better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a stab at the approach using C functions in src/native/libs/System.Native/pal_io.c
to read the data.
See: #117098
That avoids the C# code having to "know" details of the procfs structs.
Better?
BTW, I'm having trouble getting the System.Diagnostics.Process.Tests installed.
The xunit.console.dll is missing ... (found. needed to ./build.sh libs.test ...)
Thanks again.
OK, now have one prerequsites PR: #117023 Misc. illumous build fixes (prereq. for #105403) That commit is here a well because without that the code in this PR will not build. I'm not so familiar with the normal practices here, so please let me know what I can do to organize things for your convenience. Thanks. |
999cf17
to
65b4c42
Compare
src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFs.Definitions.cs
Outdated
Show resolved
Hide resolved
You can have a separate local branch with mixed changes for testing. As far as pull request is concerned, anything unrelated to |
src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFs.Definitions.cs
Outdated
Show resolved
Hide resolved
I updated this to use src/native/libs/System.Native C functions, which means we don't need to replicate the two procfs.h structures in the C# platform code. It should also be a bit more efficient. This works as well for me as the previous version I had in this PR. I also got rid of the changes in other PR(s), but note that this doesn't build for illumos without the changes in #117023 |
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessThread.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessThread.cs
Outdated
Show resolved
Hide resolved
Read /proc (binary) psinfo for System.Diagnostic.Process using src/native/libs/System.Native C functions. Add native/libs/System.Native/pal_io.c etc. Add src/libraries/Common/src/Interop/SunOS/procfs Add src/libraries/System.Diagnostics.Process Co-authored-by: Austin Wise <AustinWise@gmail.com> Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Needs approvers. @am11 ? |
Read binary psinfo for System.Diagnostic.Process on SunOS (Solaris or illumos).
No failures in System.Diagnostic.Process.Tests (but lots of skip)
BTW, I tried rebasing on main from Mon. this week and ran into problems downloading stuff.
Not sure why, but it didn't seem to have anything to do with my changes.