Skip to content

Commit 65d04cb

Browse files
committed
std.DynLib: open the fd with CLOEXEC
1 parent 48de57d commit 65d04cb

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

std/dynamic_library.zig

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,9 @@ pub const DynLib = struct {
1111
map_addr: usize,
1212
map_size: usize,
1313

14-
/// Trusts the file
15-
pub fn findAndOpen(allocator: *mem.Allocator, name: []const u8) !DynLib {
16-
return open(allocator, name);
17-
}
18-
1914
/// Trusts the file
2015
pub fn open(allocator: *mem.Allocator, path: []const u8) !DynLib {
21-
const fd = try std.os.posixOpen(allocator, path, 0, linux.O_RDONLY);
16+
const fd = try std.os.posixOpen(allocator, path, 0, linux.O_RDONLY | linux.O_CLOEXEC);
2217
errdefer std.os.close(fd);
2318

2419
const size = usize((try std.os.posixFStat(fd)).size);

std/math/index.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ test "math.cast" {
538538

539539
pub const AlignCastError = error{UnalignedMemory};
540540

541-
/// Align cast a pointer but return an error if it's the wrong field
541+
/// Align cast a pointer but return an error if it's the wrong alignment
542542
pub fn alignCast(comptime alignment: u29, ptr: var) AlignCastError!@typeOf(@alignCast(alignment, ptr)) {
543543
const addr = @ptrToInt(ptr);
544544
if (addr % alignment != 0) {

0 commit comments

Comments
 (0)