linux cgroup: fix initialization (#9043)

`std.Io.Reader.readAlloc` will fail if it can't read all of the bytes
asked for, so use `File.readToEndAlloc` instead.
pull/9050/head
Mitchell Hashimoto 2025-10-05 19:49:50 -07:00 committed by GitHub
commit b5661cc887
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 6 deletions

View File

@ -19,9 +19,7 @@ pub fn current(alloc: Allocator, pid: std.os.linux.pid_t) !?[]const u8 {
defer file.close();
// Read it all into memory -- we don't expect this file to ever be that large.
var reader_buf: [4096]u8 = undefined;
var reader = file.reader(&reader_buf);
const contents = try reader.interface.readAlloc(
const contents = try file.readToEndAlloc(
alloc,
1 * 1024 * 1024, // 1MB
);
@ -187,9 +185,7 @@ pub fn controllers(alloc: Allocator, cgroup: []const u8) ![]const u8 {
// Read it all into memory -- we don't expect this file to ever
// be that large.
var reader_buf: [4096]u8 = undefined;
var reader = file.reader(&reader_buf);
const contents = try reader.interface.readAlloc(
const contents = try file.readToEndAlloc(
alloc,
1 * 1024 * 1024, // 1MB
);