Skip to content

Instantly share code, notes, and snippets.

@Jarred-Sumner
Created June 29, 2021 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jarred-Sumner/8e37958611617212ced3524c858e098f to your computer and use it in GitHub Desktop.
Save Jarred-Sumner/8e37958611617212ced3524c858e098f to your computer and use it in GitHub Desktop.
show-ulimit.zig
const std = @import("std");
pub fn main() anyerror!void {
var out = std.io.getStdOut();
var writer = out.writer();
var str: [256]u8 = undefined;
var len = str.len;
var os_version = try std.os.sysctlbynameZ("kern.osproductversion"[0.. :0], &str, &len, null, 0);
try writer.print("macOS: {s}\nFile Descriptor Limit\n", .{str[0..len]});
if (std.os.getrlimit(.NOFILE)) |limit| {
try writer.print("Soft (current): {d}\nHard (max): {d}", .{ limit.cur, limit.max });
} else |err| {
std.log.crit("getrlimit failed: {s}", .{@errorName(err)});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment