Skip to content

Commit

Permalink
windows or whatever
Browse files Browse the repository at this point in the history
  • Loading branch information
Techatrix committed Nov 29, 2024
1 parent 1e4ec93 commit 254e96e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
16 changes: 8 additions & 8 deletions src/build_runner/master.zig
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,14 @@ pub fn main() !void {
return;
}

const suicide_thread = try std.Thread.spawn(.{}, struct {
fn do() void {
_ = std.io.getStdIn().reader().readByte() catch process.exit(1);
process.exit(0);
}
}.do, .{});
suicide_thread.detach();

if (!Watch.have_impl) return;
var w = try Watch.init();

Expand All @@ -397,14 +405,6 @@ pub fn main() !void {
else => return err,
};

const suicide_thread = try std.Thread.spawn(.{ .allocator = gpa }, struct {
fn do(t: *Transport) void {
const header = t.receiveMessage(null) catch process.exit(1);
process.exit(if (header.tag == 0) 0 else 1);
}
}.do, .{&transport});
suicide_thread.detach();

rebuild: while (true) : (run.cycle += 1) {
runSteps(
builder,
Expand Down
18 changes: 8 additions & 10 deletions src/features/diagnostics.zig
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,8 @@ pub const BuildOnSave = struct {
}

pub fn deinit(self: *BuildOnSave) void {
var transport = Transport.init(.{
.gpa = self.allocator,
.in = self.child_process.stdout.?,
.out = self.child_process.stdin.?,
});

transport.serveMessage(.{ .tag = 0, .bytes_len = 0 }, &.{}) catch |err| {
// this write tells the child process to exit
self.child_process.stdin.?.writeAll("\xaa") catch |err| {
log.warn("failed to send message to zig build runner: {}", .{err});
return;
};
Expand Down Expand Up @@ -558,9 +553,12 @@ pub const BuildOnSave = struct {
defer transport.deinit();

while (true) {
const header = transport.receiveMessage(null) catch |err| {
log.err("failed to receive message from build runner: {}", .{err});
return;
const header = transport.receiveMessage(null) catch |err| switch (err) {
error.EndOfStream => return,
else => {
log.err("failed to receive message from build runner: {}", .{err});
return;
},
};

switch (@as(ServerToClient.Tag, @enumFromInt(header.tag))) {
Expand Down

0 comments on commit 254e96e

Please sign in to comment.