[os2/process]: Refactor process_info procs, add process_info_by_handle

This commit is contained in:
flysand7
2024-07-15 07:27:44 +11:00
parent 8f4755532e
commit 4eca60946c
2 changed files with 252 additions and 64 deletions
+39 -10
View File
@@ -168,17 +168,37 @@ Process_Info :: struct {
This procedure obtains an information, specified by `selection` parameter of
a process given by `pid`.
Use `free_process_info` to free the memory allocated by this function. In
Use `free_process_info` to free the memory allocated by this procedure. In
case the function returns an error all temporary allocations would be freed
and as such, calling `free_process_info()` is not needed.
**Note**: The resulting information may or may not contain the
selected fields. Please check the `fields` field of the `Process_Info`
struct to see if the struct contains the desired fields **before** checking
the error code returned by this function.
**Note**: The resulting information may or may contain the fields specified
by the `selection` parameter. Always check whether the returned
`Process_Info` struct has the required fields before checking the error code
returned by this function.
*/
process_info :: proc(pid: int, selection: Process_Info_Fields, allocator: runtime.Allocator) -> (Process_Info, Error) {
return _process_info(pid, selection, allocator)
process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator: runtime.Allocator) -> (Process_Info, Error) {
return _process_info_by_pid(pid, selection, allocator)
}
/*
Obtain information about a process.
This procedure obtains information, specified by `selection` parameter
about a process that has been opened by the application, specified in
the `process` parameter.
Use `free_process_info` to free the memory allocated by this procedure. In
case the function returns an error, all temporary allocations would be freed
and as such, calling `free_process_info` is not needed.
**Note**: The resulting information may or may contain the fields specified
by the `selection` parameter. Always check whether the returned
`Process_Info` struct has the required fields before checking the error code
returned by this function.
*/
process_info_by_handle :: proc(process: Process, selection: Process_Info_Fields, allocator: runtime.Allocator) -> (Process_Info, Error) {
return _process_info_by_handle(process, selection, allocator)
}
/*
@@ -191,15 +211,24 @@ process_info :: proc(pid: int, selection: Process_Info_Fields, allocator: runtim
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
**Note**: The resulting information may or may contain the fields specified
by the `selection` parameter. Always check whether the returned
`Process_Info` struct has the required fields before checking the error code
returned by this function.
*/
current_process_info :: proc(selection: Process_Info_Fields, allocator: runtime.Allocator) -> (Process_Info, Error) {
return _current_process_info(selection, allocator)
}
/*
Obtain information about the specified process.
*/
process_info :: proc {
process_info_by_pid,
process_info_by_handle,
current_process_info,
}
/*
Free the information about the process.