Skip to content

Instantly share code, notes, and snippets.

@Jarred-Sumner
Created June 29, 2021 19:52
Show Gist options
  • 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