Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

SunOS process and thread support #105403

wants to merge 2 commits into from

Conversation

gwr
Copy link
Contributor

@gwr gwr commented Jul 24, 2024

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.

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jul 24, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-diagnostics-process
See info in area-owners.md if you want to be subscribed.

@am11
Copy link
Member

am11 commented Jul 24, 2024

Lets drop the changes which are already submitted in other PRs.

@am11
Copy link
Member

am11 commented Jul 24, 2024

Good start! I've left initial feedback, which I anticipate the maintainers will point out. :)

@am11 am11 added the os-SunOS SunOS, currently not officially supported label Jul 24, 2024
@gwr
Copy link
Contributor Author

gwr commented Jul 24, 2024

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.

@gwr
Copy link
Contributor Author

gwr commented Jul 24, 2024

Lets drop the changes which are already submitted in other PRs.

I'd love to, but I do not see a way to do "stacked" PRs, where one PR targets the branch of another PR.
If I drop the prerequisite changes then things break. Suggestions welcome.

@am11
Copy link
Member

am11 commented Jul 24, 2024

Create a local branch feature/illumos-port with all the miscellaneous changes. Then keep this branch only for System.Diagnostics.Port changes. You can git cherry-pick <spaces-separated commit hashes> across the branches.

Copy link
Contributor

@AustinWise AustinWise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The C# for reading from procfs and enumerating threads/processes looks good to me.

@gwr
Copy link
Contributor Author

gwr commented Aug 18, 2024

Rebased and squashed

@am11
Copy link
Member

am11 commented Aug 22, 2024

Looks good to me. Thanks for this @gwr! This is one major step to complete the shared framework on illumos-x64 and enabling msbuild/sdk. 👍

@adamsitnik, @jkotas, PTAL.

@am11
Copy link
Member

am11 commented Aug 22, 2024

@gwr fyi, we are not required to rebase for every commit merging in main branch. It's rather a busy repo so GH will likely always show you that your branch is behind by X number of commits. The maintainers can do the rebase if deemed necessary.

Read binary psinfo for System.Diagnostic.Process on SunOS

Thanks for initial prototype help from:
Austin Wise <AustinWise@gmail.com>

Add Try prefix to SunOS Interop functions
Get rid of unsafe for procfs get methods
@gwr
Copy link
Contributor Author

gwr commented Aug 22, 2024

Updated to fix a comment (nit)

@gwr
Copy link
Contributor Author

gwr commented Aug 22, 2024

@gwr fyi, we are not required to rebase for every commit merging in main branch. It's rather a busy repo so GH will likely always show you that your branch is behind by X number of commits. The maintainers can do the rebase if deemed necessary.

OK, thanks. Won't do it too often.

@gwr
Copy link
Contributor Author

gwr commented Aug 22, 2024

Here too; Can anyone tell me what to do about the runtime checks that reported failure?

@jkotas
Copy link
Member

jkotas commented Aug 22, 2024

Can anyone tell me what to do about the runtime checks that reported failure?

Don't worry about them. They are not related to your change.

@gwr
Copy link
Contributor Author

gwr commented Aug 28, 2024

nudge 2

@gwr
Copy link
Contributor Author

gwr commented Sep 12, 2024

nudge 3

@adamsitnik
Copy link
Member

Please excuse me for lack of response, I am busy fixing some last minute bugs for .NET 9. I should be less busy after the RC2 branch snap next week and I hope to be able to review it then.

@jeffhandley
Copy link
Member

Sorry for the delay on this, @gwr. I just merged main into your branch to get a fresh build.

@jeffhandley jeffhandley requested a review from Copilot March 23, 2025 21:49
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces SunOS (Solaris and illumos) support for System.Diagnostics.Process by implementing new SunOS-specific interop routines and process/thread management code. Key changes include:

  • New files for reading process and thread information from procfs on SunOS.
  • Updates to process and thread APIs to support SunOS properties and priority mapping.
  • Adjustments in test utilities and environment code to incorporate SunOS detection and behavior.

Reviewed Changes

Copilot reviewed 12 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessThread.SunOS.cs Implements SunOS thread info retrieval and property mapping.
src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFs.TryGetProcessInfoById.cs Adds support for reading process info from procfs on SunOS.
src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFs.TryGetThreadInfoById.cs Provides SunOS-specific thread info retrieval from procfs.
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.SunOS.cs Implements SunOS properties for Process, including start time and CPU time calculation.
src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFs.Definitions.cs Defines SunOS procfs structures and constants.
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.SunOS.cs Integrates process management and enumeration for SunOS.
src/libraries/Common/src/Interop/Unix/System.Native/Interop.TimeSpec.cs Introduces a TimeSpec struct for time conversions.
src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs Updates platform detection to include SunOS.
src/libraries/System.Diagnostics.Process/tests/ProcessTests.cs Adjusts tests to handle working set issues on SunOS.
src/libraries/System.Private.CoreLib/src/System/Environment.SunOS.cs Updates environment working set retrieval for SunOS.
src/libraries/Common/src/Interop/Unix/System.Native/Interop.UTimensat.cs Removes duplicate TimeSpec definition.
src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFsStat.TryReadProcessStatusInfo.cs Removes legacy status info retrieval code.
Files not reviewed (5)
  • src/libraries/System.Diagnostics.Process/src/System.Diagnostics.Process.csproj: Language not supported
  • src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems: Language not supported
  • src/native/libs/System.Native/entrypoints.c: Language not supported
  • src/native/libs/System.Native/pal_io.c: Language not supported
  • src/native/libs/System.Native/pal_io.h: Language not supported
Comments suppressed due to low confidence (1)

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs:48

  • [nitpick] Consider renaming 'Isillumos' to 'IsIllumos' for improved readability and consistency with .NET naming conventions.
public static bool Isillumos => RuntimeInformation.IsOSPlatform(OSPlatform.Create("ILLUMOS"));


// Iterate through all process IDs to load information about each process
IEnumerable<int> pids = EnumerateProcessIds();
ArrayBuilder<ProcessInfo> processes = default;
Copy link
Preview

Copilot AI Mar 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that ArrayBuilder is properly instantiated instead of using the default value to prevent potential NullReferenceExceptions when adding items.

Suggested change
ArrayBuilder<ProcessInfo> processes = default;
ArrayBuilder<ProcessInfo> processes = new ArrayBuilder<ProcessInfo>();

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Diagnostics.Process community-contribution Indicates that the PR has been added by a community member os-SunOS SunOS, currently not officially supported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants