convert all to use sys/linux over sys/unix; new implementations for pipe, process and env

This commit is contained in:
jason
2024-06-27 17:14:48 -04:00
parent f22754fc90
commit f24f72c280
12 changed files with 1269 additions and 543 deletions
+53 -35
View File
@@ -2,36 +2,42 @@ package os2
import "core:sync"
import "core:time"
import "base:runtime"
import "core:c"
args: []string
args: []string = _alloc_command_line_arguments()
exit :: proc "contextless" (code: int) -> ! {
runtime.trap()
_exit(code)
}
@(require_results)
get_uid :: proc() -> int {
return -1
return _get_uid()
}
@(require_results)
get_euid :: proc() -> int {
return -1
return _get_euid()
}
@(require_results)
get_gid :: proc() -> int {
return -1
return _get_gid()
}
@(require_results)
get_egid :: proc() -> int {
return -1
return _get_euid()
}
@(require_results)
get_pid :: proc() -> int {
return -1
return _get_pid()
}
@(require_results)
get_ppid :: proc() -> int {
return -1
return _get_ppid()
}
@@ -46,16 +52,12 @@ Process :: struct {
Process_Attributes :: struct {
dir: string,
env: []string,
files: []^File,
stdin: ^File,
stdout: ^File,
stderr: ^File,
sys: ^Process_Attributes_OS_Specific,
}
Process_Attributes_OS_Specific :: struct{}
Process_Error :: enum {
None,
}
Process_State :: struct {
pid: int,
exit_code: int,
@@ -66,37 +68,53 @@ Process_State :: struct {
sys: rawptr,
}
Signal :: #type proc()
Kill: Signal = nil
Interrupt: Signal = nil
find_process :: proc(pid: int) -> (^Process, Process_Error) {
return nil, .None
Signal :: enum {
Abort,
Floating_Point_Exception,
Illegal_Instruction,
Interrupt,
Segmentation_Fault,
Termination,
}
process_start :: proc(name: string, argv: []string, attr: ^Process_Attributes) -> (^Process, Process_Error) {
return nil, .None
Signal_Handler_Proc :: #type proc "c" (c.int)
Signal_Handler_Special :: enum {
Default,
Ignore,
}
process_release :: proc(p: ^Process) -> Process_Error {
return .None
Signal_Handler :: union {
Signal_Handler_Proc,
Signal_Handler_Special,
}
process_kill :: proc(p: ^Process) -> Process_Error {
return .None
@(require_results)
process_find :: proc(pid: int) -> (Process, Error) {
return _process_find(pid)
}
process_signal :: proc(p: ^Process, sig: Signal) -> Process_Error {
return .None
@(require_results)
process_get_state :: proc(p: Process) -> (Process_State, Error) {
return _process_get_state(p)
}
process_wait :: proc(p: ^Process) -> (Process_State, Process_Error) {
return {}, .None
@(require_results)
process_start :: proc(name: string, argv: []string, attr: ^Process_Attributes = nil) -> (Process, Error) {
return _process_start(name, argv, attr)
}
process_release :: proc(p: ^Process) -> Error {
return _process_release(p)
}
process_kill :: proc(p: ^Process) -> Error {
return _process_kill(p)
}
process_signal :: proc(sig: Signal, h: Signal_Handler) -> Error {
return _process_signal(sig, h)
}
process_wait :: proc(p: ^Process, t: time.Duration = time.MAX_DURATION) -> (Process_State, Error) {
return _process_wait(p, t)
}