Skip to content

Haiku: Process/thread management functions#121883

Open
trungnt2910 wants to merge 15 commits intodotnet:mainfrom
trungnt2910:dev/trungnt2910/haiku-lib-diagnostics
Open

Haiku: Process/thread management functions#121883
trungnt2910 wants to merge 15 commits intodotnet:mainfrom
trungnt2910:dev/trungnt2910/haiku-lib-diagnostics

Conversation

@trungnt2910
Copy link
Copy Markdown
Contributor

Add support for process/thread management functions in System.Diagnostics.Process for Haiku.

This is required to build managed runtime libraries for Haiku as well as running a simple "Hello, World!" application.

Part of #55803.

Copilot AI review requested due to automatic review settings November 21, 2025 15:01
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Nov 21, 2025
@trungnt2910
Copy link
Copy Markdown
Contributor Author

C/c @am11

I just added the relevant parts of the common files to both, then we can rebase stuff later.

Copy link
Copy Markdown
Contributor

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 adds Haiku operating system support to the System.Diagnostics.Process library, enabling process and thread management functionality for Haiku. This is part of the broader effort to support Haiku as a platform (#55803).

  • Implements Haiku-specific process/thread management APIs using native Haiku system calls
  • Adds proper platform attribute annotations for API surface compatibility
  • Integrates Haiku interop layer for process, thread, and image information

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ProcessThread.cs Adds [SupportedOSPlatform("haiku")] attributes to PriorityLevel property getter and setter
ProcessThread.Haiku.cs Implements Haiku-specific thread priority management and processor time tracking using native BeOS-style priority values
ProcessManager.Haiku.cs Implements process enumeration, module collection, and process information retrieval for Haiku using team and thread APIs
Process.cs Adds [UnsupportedOSPlatform("haiku")] attributes to working set limit properties
Process.Haiku.cs Implements Haiku-specific process properties including boot time caching, start time, processor time tracking, and platform-specific helper methods
System.Diagnostics.Process.csproj Adds Haiku target framework and includes Haiku-specific source files and interop definitions
Interop.OS.cs Defines Haiku native interop for OS-level APIs including team/thread/area/system information structures and P/Invoke declarations
Interop.Libraries.cs Defines the libroot library constant for Haiku native library imports
Interop.Image.cs Defines Haiku native interop for image (module) information APIs

@@ -100,6 +101,7 @@ public ThreadPriorityLevel PriorityLevel
return _priorityLevel.Value;
}
[SupportedOSPlatform("windows")]
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

The setter is missing [SupportedOSPlatform("linux")] and [SupportedOSPlatform("freebsd")] attributes. While these platforms throw PlatformNotSupportedException in their implementations, the attributes on the public API should match the getter's attributes to maintain consistency and accuracy in the API surface declarations. The presence of the getter attribute for these platforms indicates the API should be callable, even if it throws at runtime.

Suggested change
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("windows")]
[SupportedOSPlatform("linux")]
[SupportedOSPlatform("freebsd")]

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ignoring since it's not related to Haiku.

@trungnt2910 trungnt2910 force-pushed the dev/trungnt2910/haiku-lib-diagnostics branch from 3db3a8c to 822ecd1 Compare November 21, 2025 15:28
@trungnt2910 trungnt2910 force-pushed the dev/trungnt2910/haiku-lib-diagnostics branch from 822ecd1 to 7863bab Compare November 21, 2025 15:51
@trungnt2910 trungnt2910 force-pushed the dev/trungnt2910/haiku-lib-diagnostics branch 2 times, most recently from b7ee79c to f458cbd Compare November 22, 2025 02:53
@jeffhandley jeffhandley added the needs-author-action An issue or pull request that requires more info or actions from the author. label Feb 1, 2026
@trungnt2910
Copy link
Copy Markdown
Contributor Author

Still tracking, will take action soon.

@dotnet-policy-service dotnet-policy-service bot removed needs-author-action An issue or pull request that requires more info or actions from the author. no-recent-activity labels Feb 16, 2026
@jeffhandley
Copy link
Copy Markdown
Member

@trungnt2910 I pushed 0ee9ed3 to my fork; it merges main into your branch and resolves the conflict. Feel free to cherry-pick that commit if it's helpful.

trungnt2910 and others added 3 commits April 11, 2026 20:06
Add support for process/thread management functions in
`System.Diagnostics.Process` for Haiku.

This is required to build managed runtime libraries for Haiku as well as
running a simple "Hello, World!" application.

Co-authored-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
Declare Haiku as a supported platform to MSBuild for all
`System.Diagnostics.Process` builds.

This prevents `CA1418` when using the `SupportedOSPlatform` attribute
with `haiku`.
@trungnt2910 trungnt2910 force-pushed the dev/trungnt2910/haiku-lib-diagnostics branch from f458cbd to 5ed9cf0 Compare April 11, 2026 10:08
Copilot AI review requested due to automatic review settings April 11, 2026 10:08
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Copy link
Copy Markdown
Contributor

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.


while ((Interop.Image.GetNextImageInfo(processId, ref cookie, out info)) == 0)
{
string modulePath = GetString(info.name, Interop.Image.MAXPATHLEN);
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

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

In GetModules, info.name is a fixed buffer field; it can’t be passed directly to a byte* parameter. This likely won’t compile. Use a fixed (byte* pName = info.name) block (or change GetString to accept a span) and pass the pinned pointer.

Suggested change
string modulePath = GetString(info.name, Interop.Image.MAXPATHLEN);
string modulePath;
fixed (byte* pName = info.name)
{
modulePath = GetString(pName, Interop.Image.MAXPATHLEN);
}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Haven't seen any errors so far.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 11, 2026 12:02
trungnt2910 and others added 3 commits April 11, 2026 22:02
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Copilot AI review requested due to automatic review settings April 11, 2026 12:24
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

`System.Collections.Generic` is used by `ArrayBuilder`.

I am a victim of Copilot slop.
@trungnt2910
Copy link
Copy Markdown
Contributor Author

trungnt2910 commented Apr 11, 2026

Local builds are succeeding in both Release and Debug mode (with all my other open PRs on native components applied).

@jkotas jkotas requested a review from adamsitnik April 11, 2026 14:29
Use `ReadOnlySpan` instead of a loop.

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Copilot AI review requested due to automatic review settings April 11, 2026 14:43
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

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-haiku

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants