mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
termio/exec: move subprocess into cgroup
This commit is contained in:
@ -52,6 +52,18 @@ pub fn create(
|
||||
}
|
||||
}
|
||||
|
||||
/// Move the given PID into the given cgroup.
|
||||
pub fn moveInto(
|
||||
cgroup: []const u8,
|
||||
pid: std.os.linux.pid_t,
|
||||
) !void {
|
||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
||||
const path = try std.fmt.bufPrint(&buf, "/sys/fs/cgroup{s}/cgroup.procs", .{cgroup});
|
||||
const file = try std.fs.cwd().openFile(path, .{ .mode = .write_only });
|
||||
defer file.close();
|
||||
try file.writer().print("{}", .{pid});
|
||||
}
|
||||
|
||||
/// Returns all available cgroup controllers for the given cgroup.
|
||||
/// The cgroup should have a '/'-prefix.
|
||||
///
|
||||
|
@ -1346,8 +1346,7 @@ const Subprocess = struct {
|
||||
// If we have a cgroup set, then we want to move into that cgroup.
|
||||
if (comptime builtin.os.tag == .linux) {
|
||||
if (self.linux_cgroup) |cgroup| {
|
||||
// TODO: do it
|
||||
_ = cgroup;
|
||||
try internal_os.cgroup.moveInto(cgroup, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user