int main (int argc, char *argv[]) { struct rlimit rlim; pid_t pid = 0; int status = 0, nchildren = 3, i; /* Print out all limits */ printf ("Printing out all limits for pid=%d:\n", getpid ()); print_limits (); /* change and printout the limit for core file size */ printf ("\nBefore Modification, this is RLIMIT_CORE:\n"); do_limit (RLIMIT_CORE, "RLIMIT_CORE", &rlim); rlim.rlim_cur = 8 * 1024 * 1024; printf ("I forked off a child with pid = %d\n", (int)pid); setrlimit (RLIMIT_CORE, &rlim); printf ("\nAfter Modification, this is RLIMIT_CORE:\n"); do_limit (RLIMIT_CORE, "RLIMIT_CORE", &rlim); /* fork off the nchildren */ fflush (stdout); for (i = 0; i < nchildren; i++) { pid = fork (); if (pid < 0) DEATH ("Failed in fork"); if (pid == 0) { /* any child */ printf ("\nIn child pid= %d this is RLIMIT_CORE:\n", (int)getpid ()); do_limit (RLIMIT_CORE, "RLIMIT_CORE", &rlim); fflush (stdout); sleep (3); exit (0); } } while (pid > 0) { /* parent */ pid = wait (&status); printf ("Parent got return on pid=%dn\n", (int)pid); } printf (" **************************************************** \n"); print_rusage (RUSAGE_SELF); print_rusage (RUSAGE_CHILDREN); exit (0); }
static void gui_cb_limit (GUI_ARGS) { GUI_IAM (OTMultiEditor); do_limit (me); }
static void gui_button_cb_limit (I, GuiButtonEvent event) { (void) event; iam (OTMultiEditor); do_limit (me); }
void print_limits (void) { struct rlimit rlim; do_limit (RLIMIT_CPU, "RLIMIT_CPU", &rlim); do_limit (RLIMIT_FSIZE, "RLMIT_FSIZE", &rlim); do_limit (RLIMIT_DATA, "RLMIT_DATA", &rlim); do_limit (RLIMIT_STACK, "RLIMIT_STACK", &rlim); do_limit (RLIMIT_CORE, "RLIMIT_CORE", &rlim); do_limit (RLIMIT_RSS, "RLIMIT_RSS", &rlim); do_limit (RLIMIT_NPROC, "RLIMIT_NPROC", &rlim); do_limit (RLIMIT_NOFILE, "RLIMIT_NOFILE", &rlim); do_limit (RLIMIT_MEMLOCK, "RLIMIT_MEMLOCK", &rlim); do_limit (RLIMIT_AS, "RLIMIT_AS", &rlim); do_limit (RLIMIT_LOCKS, "RLIMIT_LOCKS", &rlim); }