Skip to content

Instantly share code, notes, and snippets.

@ichramm
Created November 22, 2012 12:26
Show Gist options
  • Save ichramm/4130936 to your computer and use it in GitHub Desktop.
Save ichramm/4130936 to your computer and use it in GitHub Desktop.
set rlimit for core file
struct rlimit rl;
memset(&rl, 0, sizeof(rl));
rl.rlim_cur = RLIM_INFINITY;
rl.rlim_max = RLIM_INFINITY;
if (setrlimit(RLIMIT_CORE, &rl)) {
fprintf(stderr, "Unable to disable core size resource limit: %s\n", strerror(errno));
}
@JonathonReinhart
Copy link

This can be simplified using designated initializers, which automatically set unspecified fields to zero:

struct rlimit rl = {
    .rlim_cur = RLIM_INFINITY,
    .rlim_max = RLIM_INFINITY,
};
if (setrlimit(RLIMIT_CORE, &rl)) {
    fprintf(stderr, "Unable to disable core size resource limit: %s\n", strerror(errno));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment