Haiku: Process/thread management functions#121883
Haiku: Process/thread management functions#121883trungnt2910 wants to merge 4 commits intodotnet:mainfrom
Conversation
|
C/c @am11 I just added the relevant parts of the common files to both, then we can rebase stuff later. |
There was a problem hiding this comment.
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")] | |||
There was a problem hiding this comment.
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.
| [SupportedOSPlatform("windows")] | |
| [SupportedOSPlatform("windows")] | |
| [SupportedOSPlatform("linux")] | |
| [SupportedOSPlatform("freebsd")] |
There was a problem hiding this comment.
Ignoring since it's not related to Haiku.
3db3a8c to
822ecd1
Compare
822ecd1 to
7863bab
Compare
b7ee79c to
f458cbd
Compare
|
Still tracking, will take action soon. |
|
@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. |
f458cbd to
5ed9cf0
Compare
| public static void GetProcessInfos(ref ArrayBuilder<ProcessInfo> builder, string? processNameFilter) | ||
| { | ||
| int cookie = 0; | ||
| Interop.OS.TeamInfo info; | ||
|
|
||
| while ((Interop.OS.GetNextTeamInfo(ref cookie, out info)) == 0) | ||
| { | ||
| ProcessInfo? pi = GetProcessInfoFromTeamInfo(ref info, processNameFilter); |
There was a problem hiding this comment.
Interop.OS.TeamInfo is declared as an unsafe struct (due to the fixed buffer). Declaring/using it here (and calling GetNextTeamInfo) requires an unsafe context; as written this method will fail to compile for the Haiku TFM. Mark the method as unsafe (or refactor the interop type to avoid requiring unsafe at call sites).
There was a problem hiding this comment.
Haven't seen any build errors so far.
| internal static ProcessInfo? CreateProcessInfo(int pid, string? processNameFilter = null) | ||
| { | ||
| // Negative PIDs aren't valid | ||
| ArgumentOutOfRangeException.ThrowIfNegative(pid); | ||
|
|
||
| Interop.OS.TeamInfo info; | ||
| int status = Interop.OS.GetTeamInfo(pid, out info); | ||
|
|
||
| if (status != 0) |
There was a problem hiding this comment.
CreateProcessInfo uses Interop.OS.TeamInfo (an unsafe struct because of the fixed buffer). This method needs to be in an unsafe context (e.g., mark it unsafe) or the interop needs to be reshaped so callers don't need unsafe; otherwise the Haiku build will fail to compile.
There was a problem hiding this comment.
Haven't seen any build errors so far.
| internal DateTime StartTimeCore | ||
| { | ||
| get | ||
| { | ||
| EnsureState(State.HaveNonExitedId); | ||
|
|
||
| Interop.OS.TeamInfo info; | ||
| int status = Interop.OS.GetTeamInfo(_processId, out info); | ||
|
|
There was a problem hiding this comment.
StartTimeCore uses Interop.OS.TeamInfo (an unsafe struct because of the fixed buffer). This getter must be in an unsafe context (e.g., mark the property/getter as unsafe) or the interop needs to be reshaped; otherwise the Haiku TFM will not compile.
There was a problem hiding this comment.
Haven't seen any build errors so far.
|
Local builds are succeeding in both Release and Debug mode (with all my other open PRs on native components applied). |
|
LGTM! |
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`.
50691e9 to
d460910
Compare
Otherwise `clang`-based builds will complain. `clang` treats the `enum`s as unsigned `int`, triggering a sign conversion warning.
Add support for process/thread management functions in
System.Diagnostics.Processfor Haiku.This is required to build managed runtime libraries for Haiku as well as running a simple "Hello, World!" application.
Part of #55803.