This code requests neovim to run in embed mode and sends a request to it to return api info.
When it is on Windows platform and using 0.11, read len is always 0.
Everything works fine on linux platform (0.11 and nightly).
windows zig nightly also works fine.
const std = @import("std");
const ChildProcess = std.ChildProcess;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
defer {
const deinit_status = gpa.deinit();
if (deinit_status == .leak) @panic("memory leak!");
}
const args = [_][]const u8{ "nvim", "--embed" };
var nvim = ChildProcess.init(&args, allocator);
// set to use pipe
nvim.stdin_behavior = .Pipe;
// set to use pipe
nvim.stdout_behavior = .Pipe;
// set ignore
nvim.stderr_behavior = .Ignore;
// try spwan
try nvim.spawn();
// get stdin and stdout pipe
const nvim_stdin = if (nvim.stdin) |val| val else @panic("not get nvim stdin!");
const nvim_stdout = if (nvim.stdout) |val| val else @panic("not get nvim stdout!");
const arr = [_]u8{ 148, 0, 60, 177, 110, 118, 105, 109, 95, 103, 101, 116, 95, 97, 112, 105, 95, 105, 110, 102, 111, 144 };
const write_len = try nvim_stdin.write(&arr);
std.log.info("write {} bytes", .{write_len});
std.time.sleep(500000000);
var res_arr = std.mem.zeroes([10000]u8);
var read_len: usize = undefined;
read_len = try nvim_stdout.read(&res_arr);
std.log.info("read {} bytes\n{any}", .{ read_len, res_arr[0..read_len] });
}