From cb229d5a269c7fbbcebdb0a0dd4261c84da3fca2 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 13 Mar 2023 17:52:29 +0100 Subject: [PATCH] nd: ping ngui at start as an in-process pipe test this is an attempt at identifying the underlying problem. unclear whether this normal behaviour on a linux kernel or something to do with zig implementation. either way, pinging the UI makes CommReadInvalidTag error disappear on startup. updates https://git.qcode.ch/nakamochi/ndg/issues/16 --- src/nd.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/nd.zig b/src/nd.zig index ab4e984..1ce8f2f 100644 --- a/src/nd.zig +++ b/src/nd.zig @@ -157,6 +157,11 @@ pub fn main() !void { // TODO: thread-safety, esp. uiwriter const uireader = ngui.stdout.?.reader(); const uiwriter = ngui.stdin.?.writer(); + // send UI a ping as the first thing to make sure pipes are working. + // https://git.qcode.ch/nakamochi/ndg/issues/16 + comm.write(gpa, uiwriter, .ping) catch |err| { + logger.err("comm.write ping: {any}", .{err}); + }; // graceful shutdown; see sigaction(2) const sa = os.Sigaction{ @@ -191,7 +196,9 @@ pub fn main() !void { }; logger.debug("got ui msg tagged {s}", .{@tagName(msg)}); switch (msg) { - .pong => {}, + .pong => { + logger.info("received pong from ngui", .{}); + }, .poweroff => { logger.info("poweroff requested; terminating", .{}); quit = true;