Commit 913f7d0450
Changed files (1)
lib
std
special
lib/std/special/start.zig
@@ -202,8 +202,8 @@ inline fn initEventLoopAndCallMain() u8 {
defer loop.deinit();
var result: u8 = undefined;
- var frame: @Frame(callMain) = undefined;
- _ = @asyncCall(&frame, &result, callMain);
+ var frame: @Frame(callMainAsync) = undefined;
+ _ = @asyncCall(&frame, &result, callMainAsync, loop);
loop.run();
return result;
}
@@ -214,6 +214,13 @@ inline fn initEventLoopAndCallMain() u8 {
return @inlineCall(callMain);
}
+fn callMainAsync(loop: *std.event.Loop) u8 {
+ // This prevents the event loop from terminating at least until main() has returned.
+ loop.beginOneEvent();
+ defer loop.finishOneEvent();
+ return callMain();
+}
+
// This is not marked inline because it is called with @asyncCall when
// there is an event loop.
fn callMain() u8 {