summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-03-09 17:09:09 -0300
committerGabriel Schneider <[email protected]>2026-06-08 23:05:18 -0300
commit4c12cb8aa39035c6ece5efad0971c6de4c2898fe (patch)
tree8a24e4dfa8941f9f407cf1e893a9374ca507e4a9 /src
parent80ba1db819a80e784a488d6d660a890e14b19282 (diff)
downloadcodenomicon-4c12cb8aa39035c6ece5efad0971c6de4c2898fe.tar.gz
codenomicon-4c12cb8aa39035c6ece5efad0971c6de4c2898fe.zip
some changes to build.zig
Diffstat (limited to 'src')
-rw-r--r--src/shock.zig44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/shock.zig b/src/shock.zig
index 262b176..90e6edf 100644
--- a/src/shock.zig
+++ b/src/shock.zig
@@ -1,4 +1,5 @@
const std = @import("std");
+const elfo = @import("elfo.zig");
pub fn main(init: std.process.Init.Minimal) !void {
var args = init.args.iterate();
@@ -10,21 +11,21 @@ pub fn main(init: std.process.Init.Minimal) !void {
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, .{
+ var threaded: std.Io.Threaded = .init(alloc, .{
.argv0 = .init(init.args),
.environ = init.environ,
- .backing_allocator_needs_mutex = false,
});
- defer evented.deinit();
- const io = evented.io();
+ 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});
@@ -36,10 +37,23 @@ pub fn main(init: std.process.Init.Minimal) !void {
const buf = try alloc.alloc(u8, 0x400);
defer alloc.free(buf);
- _ = try child.stdout.?.readPositionalAll(io, buf, 0);
+ _ = try child.stdout.?.readStreaming(io, &.{buf});
std.debug.print("spawned child: {any}\n", .{child});
- const term = try child.wait(io);
- std.debug.print("waited term: {any}\n", .{term});
+ // io.async(function: anytype, args: (unknown type))
+ var child_fut = io.async(std.process.Child.wait, .{ &child, io });
+ const child_out = try child_fut.await(io);
+ // const child_out = try child.wait(io);
+ std.debug.print("stdout: {s}\n", .{buf});
+
+ {
+ var buffer: [64]u8 = undefined;
+ const stderr = try io.lockStderr(&buffer, .escape_codes);
+ defer io.unlockStderr();
+ const term = stderr.terminal();
+ try elfo.printHexdump(u8, term.writer, term, buf, 0);
+ }
+
+ std.debug.print("waited term: {any}\n", .{child_out});
}