1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-24 11:19:35 +01:00

Merge pull request #14618 from jonhermansen/freebsd-path-null-terminator

fix(FreeBSD): remove null terminator from executable path
This commit is contained in:
Sergei Zimmerman 2025-11-22 11:51:01 +00:00 committed by GitHub
commit ed176cb42e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -134,6 +134,11 @@ std::optional<Path> getSelfExe()
return std::nullopt;
}
// FreeBSD's sysctl(KERN_PROC_PATHNAME) includes the null terminator in
// pathLen. Strip it to prevent Nix evaluation errors when the path is
// serialized to JSON and evaluated as a Nix string.
path.pop_back();
return Path(path.begin(), path.end());
#else
return std::nullopt;