diff options
| author | Gabriel Schneider <[email protected]> | 2026-03-05 13:00:01 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-06-08 23:04:50 -0300 |
| commit | 80ba1db819a80e784a488d6d660a890e14b19282 (patch) | |
| tree | da005b5161094f24349c56acd149e4e89876410d /src/shock.zig | |
| parent | 70388a8fc6770c797c6f298886e90c982b2c721f (diff) | |
| download | codenomicon-80ba1db819a80e784a488d6d660a890e14b19282.tar.gz codenomicon-80ba1db819a80e784a488d6d660a890e14b19282.zip | |
simple shock
Diffstat (limited to 'src/shock.zig')
| -rw-r--r-- | src/shock.zig | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/shock.zig b/src/shock.zig new file mode 100644 index 0000000..262b176 --- /dev/null +++ b/src/shock.zig @@ -0,0 +1,45 @@ +const std = @import("std"); + +pub fn main(init: std.process.Init.Minimal) !void { + var args = init.args.iterate(); + _ = args.skip(); + const subject = args.next() orelse "./study-samples/frog"; + + std.debug.print("arg: {s}\n", .{subject}); + + var debug_alloc: std.heap.DebugAllocator(.{}) = .init; + const alloc = debug_alloc.allocator(); + + // var threaded: std.Io.Threaded = .init(alloc, .{ + // .argv0 = .init(init.args), + // .environ = init.environ, + // }); + // defer threaded.deinit(); + // const io = threaded.io(); + + var evented: std.Io.Evented = undefined; + try evented.init(alloc, .{ + .argv0 = .init(init.args), + .environ = init.environ, + .backing_allocator_needs_mutex = false, + }); + defer evented.deinit(); + const io = evented.io(); + + // const f = try std.Io.Dir.cwd().openFile(io, subject, .{ .mode = .read_only }); + // std.debug.print("file: {any}\n", .{f}); + var child = try std.process.spawn(io, .{ + .argv = &.{subject}, + .stdout = .pipe, + .stdin = .inherit, + }); + + const buf = try alloc.alloc(u8, 0x400); + defer alloc.free(buf); + _ = try child.stdout.?.readPositionalAll(io, buf, 0); + + std.debug.print("spawned child: {any}\n", .{child}); + + const term = try child.wait(io); + std.debug.print("waited term: {any}\n", .{term}); +} |
