mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 01:06:08 +03:00
os: rename linux => cgroup
This commit is contained in:
@ -20,7 +20,7 @@ pub fn init(app: *App) ![]const u8 {
|
|||||||
|
|
||||||
// Get our initial cgroup. We need this so we can compare
|
// Get our initial cgroup. We need this so we can compare
|
||||||
// and detect when we've switched to our transient group.
|
// and detect when we've switched to our transient group.
|
||||||
const original = try internal_os.linux.cgroupPath(
|
const original = try internal_os.cgroup.current(
|
||||||
alloc,
|
alloc,
|
||||||
pid,
|
pid,
|
||||||
) orelse "";
|
) orelse "";
|
||||||
@ -31,7 +31,7 @@ pub fn init(app: *App) ![]const u8 {
|
|||||||
// to do a dumb busy loop to wait for the move to complete.
|
// to do a dumb busy loop to wait for the move to complete.
|
||||||
try createScope(connection);
|
try createScope(connection);
|
||||||
const transient = transient: while (true) {
|
const transient = transient: while (true) {
|
||||||
const current = try internal_os.linux.cgroupPath(
|
const current = try internal_os.cgroup.current(
|
||||||
alloc,
|
alloc,
|
||||||
pid,
|
pid,
|
||||||
) orelse "";
|
) orelse "";
|
||||||
@ -52,7 +52,7 @@ pub fn init(app: *App) ![]const u8 {
|
|||||||
|
|
||||||
/// Enable all the cgroup controllers for the given cgroup.
|
/// Enable all the cgroup controllers for the given cgroup.
|
||||||
fn enableControllers(alloc: Allocator, cgroup: []const u8) !void {
|
fn enableControllers(alloc: Allocator, cgroup: []const u8) !void {
|
||||||
const raw = try internal_os.linux.cgroupControllers(alloc, cgroup);
|
const raw = try internal_os.cgroup.controllers(alloc, cgroup);
|
||||||
defer alloc.free(raw);
|
defer alloc.free(raw);
|
||||||
|
|
||||||
// Build our string builder for enabling all controllers
|
// Build our string builder for enabling all controllers
|
||||||
|
@ -3,7 +3,7 @@ const assert = std.debug.assert;
|
|||||||
const Allocator = std.mem.Allocator;
|
const Allocator = std.mem.Allocator;
|
||||||
|
|
||||||
/// Returns the path to the cgroup for the given pid.
|
/// Returns the path to the cgroup for the given pid.
|
||||||
pub fn cgroupPath(alloc: Allocator, pid: std.os.linux.pid_t) !?[]const u8 {
|
pub fn current(alloc: Allocator, pid: std.os.linux.pid_t) !?[]const u8 {
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
||||||
|
|
||||||
// Read our cgroup by opening /proc/<pid>/cgroup and reading the first
|
// Read our cgroup by opening /proc/<pid>/cgroup and reading the first
|
||||||
@ -35,7 +35,7 @@ pub fn cgroupPath(alloc: Allocator, pid: std.os.linux.pid_t) !?[]const u8 {
|
|||||||
/// controllers from the /sys/fs directory. This avoids some extra
|
/// controllers from the /sys/fs directory. This avoids some extra
|
||||||
/// work since creating an iterator over this is easy and much cheaper
|
/// work since creating an iterator over this is easy and much cheaper
|
||||||
/// than allocating a bunch of copies for an array.
|
/// than allocating a bunch of copies for an array.
|
||||||
pub fn cgroupControllers(alloc: Allocator, cgroup: []const u8) ![]const u8 {
|
pub fn controllers(alloc: Allocator, cgroup: []const u8) ![]const u8 {
|
||||||
assert(cgroup[0] == '/');
|
assert(cgroup[0] == '/');
|
||||||
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
var buf: [std.fs.MAX_PATH_BYTES]u8 = undefined;
|
||||||
|
|
@ -13,7 +13,7 @@ pub usingnamespace @import("open.zig");
|
|||||||
pub usingnamespace @import("pipe.zig");
|
pub usingnamespace @import("pipe.zig");
|
||||||
pub usingnamespace @import("resourcesdir.zig");
|
pub usingnamespace @import("resourcesdir.zig");
|
||||||
pub const TempDir = @import("TempDir.zig");
|
pub const TempDir = @import("TempDir.zig");
|
||||||
pub const linux = @import("linux.zig");
|
pub const cgroup = @import("cgroup.zig");
|
||||||
pub const passwd = @import("passwd.zig");
|
pub const passwd = @import("passwd.zig");
|
||||||
pub const xdg = @import("xdg.zig");
|
pub const xdg = @import("xdg.zig");
|
||||||
pub const windows = @import("windows.zig");
|
pub const windows = @import("windows.zig");
|
||||||
|
Reference in New Issue
Block a user