mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 22:58:46 +00:00
os2: initial implementation for Darwin&BSDs, process API is only thing incomplete
This commit is contained in:
@@ -14,7 +14,7 @@ TIMEOUT_INFINITE :: time.MIN_DURATION // Note(flysand): Any negative duration wi
|
||||
*/
|
||||
args := get_args()
|
||||
|
||||
@(private="file", require_results)
|
||||
@(private="file")
|
||||
get_args :: proc() -> []string {
|
||||
result := make([]string, len(runtime.args__), heap_allocator())
|
||||
for rt_arg, i in runtime.args__ {
|
||||
@@ -131,6 +131,8 @@ Process_Info_Field :: enum {
|
||||
Working_Dir,
|
||||
}
|
||||
|
||||
ALL_INFO :: Process_Info_Fields{.Executable_Path, .PPid, .Priority, .Command_Line, .Command_Args, .Environment, .Username, .Working_Dir}
|
||||
|
||||
/*
|
||||
Contains information about the process as obtained by the `process_info()`
|
||||
procedure.
|
||||
@@ -166,8 +168,8 @@ Process_Info :: struct {
|
||||
a process given by `pid`.
|
||||
|
||||
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.
|
||||
case the function returns an error it may only have been an error for one part
|
||||
of the information and you would still need to call it to free the other parts.
|
||||
|
||||
**Note**: The resulting information may or may contain the fields specified
|
||||
by the `selection` parameter. Always check whether the returned
|
||||
@@ -187,8 +189,8 @@ process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator:
|
||||
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.
|
||||
case the function returns an error it may only have been an error for one part
|
||||
of the information and you would still need to call it to free the other parts.
|
||||
|
||||
**Note**: The resulting information may or may contain the fields specified
|
||||
by the `selection` parameter. Always check whether the returned
|
||||
@@ -206,9 +208,9 @@ process_info_by_handle :: proc(process: Process, selection: Process_Info_Fields,
|
||||
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.
|
||||
Use `free_process_info` to free the memory allocated by this procedure. In
|
||||
case the function returns an error it may only have been an error for one part
|
||||
of the information and you would still need to call it to free the other parts.
|
||||
|
||||
**Note**: The resulting information may or may contain the fields specified
|
||||
by the `selection` parameter. Always check whether the returned
|
||||
@@ -239,12 +241,16 @@ process_info :: proc {
|
||||
free_process_info :: proc(pi: Process_Info, allocator: runtime.Allocator) {
|
||||
delete(pi.executable_path, allocator)
|
||||
delete(pi.command_line, allocator)
|
||||
for a in pi.command_args {
|
||||
delete(a, allocator)
|
||||
}
|
||||
delete(pi.command_args, allocator)
|
||||
for s in pi.environment {
|
||||
delete(s, allocator)
|
||||
}
|
||||
delete(pi.environment, allocator)
|
||||
delete(pi.working_dir, allocator)
|
||||
delete(pi.username, allocator)
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user