mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 01:06: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.
|
/// Returns all available cgroup controllers for the given cgroup.
|
||||||
/// The cgroup should have a '/'-prefix.
|
/// 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 we have a cgroup set, then we want to move into that cgroup.
|
||||||
if (comptime builtin.os.tag == .linux) {
|
if (comptime builtin.os.tag == .linux) {
|
||||||
if (self.linux_cgroup) |cgroup| {
|
if (self.linux_cgroup) |cgroup| {
|
||||||
// TODO: do it
|
try internal_os.cgroup.moveInto(cgroup, 0);
|
||||||
_ = cgroup;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user