master
 1const std = @import("std");
 2
 3pub fn main() !void {
 4    var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init;
 5    defer std.debug.assert(gpa.deinit() == .ok);
 6    const allocator = gpa.allocator();
 7
 8    const self_path = try std.fs.selfExePathAlloc(allocator);
 9    defer allocator.free(self_path);
10
11    var self_exe = try std.fs.openSelfExe(.{});
12    defer self_exe.close();
13    var buf: [std.fs.max_path_bytes]u8 = undefined;
14    const self_exe_path = try std.os.getFdPath(self_exe.handle, &buf);
15
16    try std.testing.expectEqualStrings(self_exe_path, self_path);
17}