Simple example of using Odin to spawn a sub process (in this case another odin app), take a handle of stdin and stdout for the subprocess in order to be able to communicate with it.
Written naively in an effort to play with file handlers and buffered readers.
message_process :: proc(msg: string, pipes: ProcessPipes) {...}
Handles writing a message to subprocesses stdin transmuting the string to a []u8 before writing.
read_line :: proc(pipe: ^os.File) -> string {...}
Uses a buffered reader similar to the latter example from this article. Using a context.allocator as the message could go over the buffer, so we might need to join together.
start_process :: proc(process_name: string) -> (subprocess: SubProcess, err: os.Error) {...}
Relies on os2's os.process_start to spawn the process and return the required pipes to communicate properly.
Testing done with Makefile to run both processes
make test
Building example_process...
odin build ./example_process/example_process.odin -file
odin run .
Output: hellope
Output: subprocess
Output: here
Final response: quit received, exiting