Skip to content

Conversation

@trungnt2910
Copy link
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
Contributor Author

C/c @am11

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

@dotnet-policy-service
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 am11 added the os-haiku label Nov 21, 2025
Copilot finished reviewing on behalf of trungnt2910 November 21, 2025 15:06
Copy link
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

}
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
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
Comment on lines +33 to +34
public delegate* unmanaged<void> init_routine;
public delegate* unmanaged<void> term_routine;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: if it's not interested to invoke them from managed code, you can define them as opaque IntPtr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe an opaque void* instead, since the other members are void*?

Those two correspond to https://github.com/haiku/haiku/blob/d39ce117e02d3d8aac966b1a46bd955a2b59c069/headers/os/kernel/image.h#L27-L28 in the Haiku source.

	void		(*init_routine)();
	void		(*term_routine)();

Copy link
Member

Choose a reason for hiding this comment

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

Semantic-wise void* is incorrect because function pointers can't be dereferenced. In C function pointers can't be casted to void* either. IntPtr is correct for opaque pointer-size field. Unmanaged function pointer is precise but unnecessary.

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>
@trungnt2910 trungnt2910 force-pushed the dev/trungnt2910/haiku-lib-diagnostics branch from 822ecd1 to 7863bab Compare November 21, 2025 15:51
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 b7ee79c to f458cbd Compare November 22, 2025 02:53
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.

3 participants