| 1 | const std = @import("std"); |
| 2 | |
| 3 | pub fn main(init: std.process.Init) !void { |
| 4 | const gpa = init.gpa; |
| 5 | const io = init.io; |
| 6 | |
| 7 | const self_path = try std.process.executablePathAlloc(io, gpa); |
| 8 | defer gpa.free(self_path); |
| 9 | |
| 10 | var self_exe = try std.process.openExecutable(io, .{}); |
| 11 | defer self_exe.close(io); |
| 12 | |
| 13 | var buf: [std.fs.max_path_bytes]u8 = undefined; |
| 14 | const self_exe_path = buf[0..try self_exe.realPath(io, &buf)]; |
| 15 | |
| 16 | try std.testing.expectEqualStrings(self_exe_path, self_path); |
| 17 | } |