[os2/process]: Improve documentation for *process_info() family of function

This commit is contained in:
flysand7
2024-07-15 07:27:43 +11:00
parent f3d4a734d8
commit c1f5d8f006
+22 -5
View File
@@ -133,6 +133,8 @@ Process_Info_Field :: enum {
procedure. procedure.
*/ */
Process_Info :: struct { Process_Info :: struct {
// The information about a process the struct contains. `pid` is always
// stored, no matter what.
fields: Process_Info_Fields, fields: Process_Info_Fields,
// The ID of the process. // The ID of the process.
pid: int, pid: int,
@@ -157,22 +159,37 @@ Process_Info :: struct {
/* /*
Obtain information about a process. Obtain information about a process.
This procedure obtains an information, given by `selection` parameter of This procedure obtains an information, specified by `selection` parameter of
a process given by `pid`. a process given by `pid`.
Use `free_process_info` to free memory allocated by this function. In case Use `free_process_info` to free the memory allocated by this function. In
the function returns an error all temporary allocations would be freed and case the function returns an error all temporary allocations would be freed
as such, calling `free_process_info()` is not needed. and as such, calling `free_process_info()` is not needed.
**Note**: The resulting information may or may not contain the **Note**: The resulting information may or may not contain the
selected fields. Please check the `fields` field of the `Process_Info` selected fields. Please check the `fields` field of the `Process_Info`
struct to see if the struct contains the desired fields **before** checking struct to see if the struct contains the desired fields **before** checking
the error return of this function. the error code returned by this function.
*/ */
process_info :: proc(pid: int, selection: Process_Info_Fields, allocator: runtime.Allocator) -> (Process_Info, Error) { process_info :: proc(pid: int, selection: Process_Info_Fields, allocator: runtime.Allocator) -> (Process_Info, Error) {
return _process_info(pid, selection, allocator) return _process_info(pid, selection, allocator)
} }
/*
Obtain information about the current process.
This procedure obtains the information, specified by `selection` parameter
about the currently running process.
Use `free_process_info` to free the memory allocated by this function. In
case this function returns an error, all temporary allocations would be
freed and as such calling `free_process_info()` is not needed.
**Note**: The resulting `Process_Info` may or may not contain the selected
fields. Check the `fields` field of the `Process_Info` struct to see, if the
struct contains the selected fields **before** checking the error code
returned by this function.
*/
current_process_info :: proc(selection: Process_Info_Fields, allocator: runtime.Allocator) -> (Process_Info, Error) { current_process_info :: proc(selection: Process_Info_Fields, allocator: runtime.Allocator) -> (Process_Info, Error) {
return _current_process_info(selection, allocator) return _current_process_info(selection, allocator)
} }