/*-------------------------------------------------------------------*/ /* testsetrlimit.c */ /* The setrlimit system call. */ /*-------------------------------------------------------------------*/ #include #include #include int main(int argc, char *argv[]) { struct rlimit sRlimit; /* Set the process's CPU limit. */ sRlimit.rlim_cur = 5; /* seconds */ sRlimit.rlim_max = 5; /* seconds */ setrlimit(RLIMIT_CPU, &sRlimit); printf("Entering an infinite loop\n"); for (;;) ; return 0; } /* Sample execution: --> gcc -Wall -ansi -pedantic -o testsetrlimit testsetrlimit.c --> testsetrlimit Entering an infinite loop Cpu Limit Exceeded (core dumped) --> */