cl-rlimit
2015-06-08
Simple interface to Unix getrlimit and setrlimit.
For further reference see man getrlimit(2) and man getrusage(2).
1rlimit, (setf rlimit)
function /rlimit/ resource -> current, max
function /(setf rlimit)/ resource size -> size-or-error
size should be an integer. resource should be one of:
+RLIMIT-ADDRESS-SPACE+or+RLIMIT-AS++RLIMIT-CORE++RLIMIT-CPU+or+RLIMIT-CPU-TIME++RLIMIT-DATA++RLIMIT-FILE-SIZE+or+RLIMIT-FSIZE++RLIMIT-MEMLOCK++RLIMIT-MSGQUEUE++RLIMIT-NICE++RLIMIT-NOFILE+or ++RLIMIT-NUMBER-OF-FILES++RLIMIT-NPROC+or+RLIMIT-NUMBER-OF-PROCESSES++RLIMIT-OFILE++RLIMIT-REAL-TIME-PRIORITY++RLIMIT-RSS++RLIMIT-RTPRIO++RLIMIT-SIGPENDING++RLIMIT-STACK+
some of these are synonyms. To set a limit as infinity, use
+RLIM-INFINITY+
If the values to be set are inappropriate (exceeds the current limit),
it returns the appropriate errors like +EFAULT+,+EINVAL+,+EPERM+,+ESRCH+.
2rusage
(rusage &optional (who +RUSAGE-SELF+))
This takes one of +RUSAGE-SELF+, +RUSAGE-CHILDREN+, +RUSAGE-THREAD
and returns a lisp structure rusage. utime and stime is converted
to a full microsecond (combining tv_sec and tv_usec).
(defstruct rusage
(utime 0 :type integer)
(stime 0 :type integer)
(maxrss 0 :type integer)
(ixrss 0 :type integer) ;x on linux
(idrss 0 :type integer) ;x on linux
(isrss 0 :type integer) ;x on linux
(minflt 0 :type integer)
(majflt 0 :type integer)
(nswap 0 :type integer) ;x on linux
(inblock 0 :type integer)
(oublock 0 :type integer)
(msgsnd 0 :type integer) ;x on linux
(msgrcv 0 :type integer) ;x on linux
(nsignals 0 :type integer) ;x on linux
(nvcsw 0 :type integer)
(nivcsw 0 :type integer))
3TODOs
- DONE: further support for
struct rusage - TODO: signal a lisp condition instread of error integers
- TODO: integration to OSICAT-POSIX
Author: Masataro Asai guicho2.71828-at-gmail-dot-com