mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
[os2/process]: Implement process_kill
This commit is contained in:
+10
-40
@@ -26,11 +26,11 @@ args := get_args()
|
|||||||
typically is the path to the currently running executable.
|
typically is the path to the currently running executable.
|
||||||
*/
|
*/
|
||||||
get_args :: proc() -> []string {
|
get_args :: proc() -> []string {
|
||||||
args := make([]string, len(runtime.args__), allocator = context.allocator)
|
result := make([]string, len(runtime.args__), allocator = context.allocator)
|
||||||
for rt_arg, i in runtime.args__ {
|
for rt_arg, i in runtime.args__ {
|
||||||
args[i] = cast(string) rt_arg
|
result[i] = cast(string) rt_arg
|
||||||
}
|
}
|
||||||
return args[:]
|
return result[:]
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -387,42 +387,12 @@ process_close :: proc(process: Process) -> (Error) {
|
|||||||
return _process_close(process)
|
return _process_close(process)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process_Attributes :: struct {
|
/*
|
||||||
// dir: string,
|
Terminate a process.
|
||||||
// env: []string,
|
|
||||||
// files: []^File,
|
|
||||||
// sys: ^Process_Attributes_OS_Specific,
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Process_Attributes_OS_Specific :: struct{}
|
|
||||||
|
|
||||||
// Process_Error :: enum {
|
|
||||||
// None,
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Signal :: #type proc()
|
|
||||||
|
|
||||||
// Kill: Signal = nil
|
|
||||||
// Interrupt: Signal = nil
|
|
||||||
|
|
||||||
// process_start :: proc(name: string, argv: []string, attr: ^Process_Attributes) -> (^Process, Process_Error) {
|
|
||||||
// return nil, .None
|
|
||||||
// }
|
|
||||||
|
|
||||||
// process_release :: proc(p: ^Process) -> Process_Error {
|
|
||||||
// return .None
|
|
||||||
// }
|
|
||||||
|
|
||||||
// process_kill :: proc(p: ^Process) -> Process_Error {
|
|
||||||
// return .None
|
|
||||||
// }
|
|
||||||
|
|
||||||
// process_signal :: proc(p: ^Process, sig: Signal) -> Process_Error {
|
|
||||||
// return .None
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
This procedure terminates a process, specified by it's handle, `process`.
|
||||||
|
|
||||||
|
*/
|
||||||
|
process_kill :: proc(process: Process) -> (Error) {
|
||||||
|
return _process_kill(process)
|
||||||
|
}
|
||||||
|
|||||||
@@ -577,6 +577,13 @@ _process_close :: proc(process: Process) -> (Error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_process_kill :: proc(process: Process) -> (Error) {
|
||||||
|
if !windows.TerminateProcess(windows.HANDLE(process.handle), 9) {
|
||||||
|
return _get_platform_error()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
@(private)
|
@(private)
|
||||||
_filetime_to_duration :: proc(filetime: windows.FILETIME) -> time.Duration {
|
_filetime_to_duration :: proc(filetime: windows.FILETIME) -> time.Duration {
|
||||||
ticks := u64(filetime.dwHighDateTime)<<32 | u64(filetime.dwLowDateTime)
|
ticks := u64(filetime.dwHighDateTime)<<32 | u64(filetime.dwLowDateTime)
|
||||||
@@ -695,8 +702,8 @@ _parse_command_line :: proc(cmd_line_w: [^]u16, allocator: runtime.Allocator) ->
|
|||||||
for arg_w, i in argv_w[:argc] {
|
for arg_w, i in argv_w[:argc] {
|
||||||
arg, arg_err := windows.wstring_to_utf8(arg_w, -1, allocator)
|
arg, arg_err := windows.wstring_to_utf8(arg_w, -1, allocator)
|
||||||
if arg_err != nil {
|
if arg_err != nil {
|
||||||
for arg in argv[:i] {
|
for s in argv[:i] {
|
||||||
delete(arg, allocator)
|
delete(s, allocator)
|
||||||
}
|
}
|
||||||
delete(argv, allocator)
|
delete(argv, allocator)
|
||||||
return nil, arg_err
|
return nil, arg_err
|
||||||
|
|||||||
Reference in New Issue
Block a user