mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Windows was defaulting to the std handles of the current process, which is wrong
This commit is contained in:
@@ -431,17 +431,43 @@ _process_start :: proc(desc: Process_Desc) -> (process: Process, err: Error) {
|
|||||||
}
|
}
|
||||||
environment_block := _build_environment_block(environment, temp_allocator())
|
environment_block := _build_environment_block(environment, temp_allocator())
|
||||||
environment_block_w := win32_utf8_to_utf16(environment_block, temp_allocator()) or_return
|
environment_block_w := win32_utf8_to_utf16(environment_block, temp_allocator()) or_return
|
||||||
stderr_handle := win32.GetStdHandle(win32.STD_ERROR_HANDLE)
|
|
||||||
stdout_handle := win32.GetStdHandle(win32.STD_OUTPUT_HANDLE)
|
|
||||||
stdin_handle := win32.GetStdHandle(win32.STD_INPUT_HANDLE)
|
|
||||||
|
|
||||||
if desc.stdout != nil {
|
stderr_handle: win32.HANDLE
|
||||||
|
stdout_handle: win32.HANDLE
|
||||||
|
stdin_handle: win32.HANDLE
|
||||||
|
|
||||||
|
null_handle: win32.HANDLE
|
||||||
|
if desc.stdout != nil || desc.stderr != nil || desc.stdin != nil {
|
||||||
|
null_handle := win32.CreateFileW(
|
||||||
|
win32.L("NUL"),
|
||||||
|
win32.GENERIC_READ|win32.GENERIC_WRITE,
|
||||||
|
win32.FILE_SHARE_READ|win32.FILE_SHARE_WRITE,
|
||||||
|
&win32.SECURITY_ATTRIBUTES{
|
||||||
|
nLength = size_of(win32.SECURITY_ATTRIBUTES),
|
||||||
|
bInheritHandle = true,
|
||||||
|
},
|
||||||
|
win32.OPEN_EXISTING,
|
||||||
|
win32.FILE_ATTRIBUTE_NORMAL,
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
assert(null_handle != nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
if desc.stdout == nil {
|
||||||
|
stdout_handle = null_handle
|
||||||
|
} else {
|
||||||
stdout_handle = win32.HANDLE((^File_Impl)(desc.stdout.impl).fd)
|
stdout_handle = win32.HANDLE((^File_Impl)(desc.stdout.impl).fd)
|
||||||
}
|
}
|
||||||
if desc.stderr != nil {
|
|
||||||
|
if desc.stderr == nil {
|
||||||
|
stderr_handle = null_handle
|
||||||
|
} else {
|
||||||
stderr_handle = win32.HANDLE((^File_Impl)(desc.stderr.impl).fd)
|
stderr_handle = win32.HANDLE((^File_Impl)(desc.stderr.impl).fd)
|
||||||
}
|
}
|
||||||
if desc.stdin != nil {
|
|
||||||
|
if desc.stdin == nil {
|
||||||
|
stdin_handle = null_handle
|
||||||
|
} else {
|
||||||
stdin_handle = win32.HANDLE((^File_Impl)(desc.stdin.impl).fd)
|
stdin_handle = win32.HANDLE((^File_Impl)(desc.stdin.impl).fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user