My initial goal was to expose runtime info to the user assuming they can’t see stdout like how jupyter exposes /run/user/$(id -u)/jupyter/*.json files to show port number and other info. Given I’m fairly sure that is /run/user not an option on macos, I’ve settled for using unix sockets.
This is a small example of what I’m doing:
const std = @import("std");
pub fn main(init: std.process.Init) !void {
const io = init.io;
const address = try std.Io.net.UnixAddress.init("./sock");
var serv = try address.listen(io, .{});
defer serv.deinit(io);
var sock = try serv.accept(io);
defer sock.close(io);
var wBuff: [1024]u8 = undefined;
var writer = sock.writer(io, &wBuff);
try writer.interface.print("hello", .{});
try writer.interface.flush();
}
My problem is that the socket is not removed after calling .deinit blocking attempts at using the same address without removing it like a file.
rm ./sock
Is there anyway of cleaning it up properly within zig that is better than std.Io.Dir.deleteFile?
I’ve included the premise to avoid it becoming an X Y problem.