Skip to content

Common lisp interface to unix rlimit -- ensure the performance of your program!

Notifications You must be signed in to change notification settings

guicho271828/cl-rlimit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple interface to Unix getrlimit and setrlimit. For further reference see man getrlimit(2) and man getrusage(2).

rlimit, (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+.

rusage

(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))

TODOs

  • 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

About

Common lisp interface to unix rlimit -- ensure the performance of your program!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published