Does SIGXCPU work under AIX 3.1?
Vic Abell
abe at mace.cc.purdue.edu
Wed Feb 27 01:26:54 AEST 1991
The attached test program works under BSD 4.3-Tahoe, Ultrix 2.2, SunOS
4.0.3, NeXTOS 1.0 and DYNIX 3.0.12. It doesn't work under AIX 3.1
(3003). What else do I need do to limit CPU time?
Csh's "limit cputime nnn" command doesn't seem to work, either.
Vic Abell <abe at mace.cc.purdue.edu>
#include <stdio.h>
#include <signal.h>
#include <sys/resource.h>
#define TIMEOUT 20
#define NEWLIM 1
void
cpulim()
{
(void) fprintf(stderr, "CPU time limit signal received\n");
exit(0);
}
void
timeout()
{
(void) fprintf(stderr, "%d second alarm rang\n", TIMEOUT);
exit(1);
}
main()
{
struct rlimit r;
if (getrlimit(RLIMIT_CPU, &r) != 0) {
perror("getrlimit(RLIMIT_CPU)");
exit(1);
}
(void) fprintf(stderr, "current (soft) RLIMIT_CPU = %d\n", r.rlim_cur);
r.rlim_cur = NEWLIM;
if (setrlimit(RLIMIT_CPU, &r) != 0) {
perror("setrlimit(RLIMIT_CPU)");
exit(1);
}
(void) fprintf(stderr, "new (soft) RLIMIT_CPU = %d\n", NEWLIM);
(void) signal (SIGALRM, timeout);
(void) signal(SIGXCPU, cpulim);
alarm(TIMEOUT);
for(;;)
;
/* NOTREACHED */
}
More information about the Comp.unix.aix
mailing list