andrewrk / poop

Performance Optimizer Observation Platform
MIT License
788 stars 50 forks source link

show command stderr of failure #33

Closed dweiller closed 1 year ago

dweiller commented 1 year ago

Now without a deadlock.

I've testing against this program with byte count up to 100 000 000 000:

pub fn main() !void {
    const stderr = std.io.getStdErr();

    const byte_count = if (std.os.argv.len > 1)
        try std.fmt.parseInt(usize, std.mem.span(std.os.argv[1]), 10)
    else
        1 << 20;

    const bytes = "DeadLock" ** 512;

    var bytes_written: usize = 0;
    while (bytes_written + bytes.len <= byte_count) {
        bytes_written += try stderr.write(bytes);
    }

    if (bytes_written < byte_count) {
        try stderr.writeAll(bytes[0..][0 .. byte_count - bytes_written]);
    }

    std.process.exit(1);
}

const std = @import("std");
andrewrk commented 1 year ago

Thanks for the follow-up!