ulimit.h revision 3e14f97f673e8a630f076077de35afdd43dc1587
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/***********************************************************************
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* This software is part of the ast package *
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner* Copyright (c) 1982-2010 AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* and is licensed under the *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Common Public License, Version 1.0 *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin* by AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* A copy of the License is available at *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* http://www.opensource.org/licenses/cpl1.0.txt *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Information and Software Systems Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* AT&T Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Florham Park NJ *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* David Korn <dgk@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin***********************************************************************/
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#pragma prototyped
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef _ULIMIT_H
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define _ULIMIT_H 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * This is for the ulimit built-in command
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include "FEATURE/time"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include "FEATURE/rlimits"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if defined(_sys_resource) && defined(_lib_getrlimit)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# include <sys/resource.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# if !defined(RLIMIT_FSIZE) && defined(_sys_vlimit)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin /* This handles hp/ux problem */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# include <sys/vlimit.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_FSIZE (LIM_FSIZE-1)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_DATA (LIM_DATA-1)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_STACK (LIM_STACK-1)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_CORE (LIM_CORE-1)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_CPU (LIM_CPU-1)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# ifdef LIM_MAXRSS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_RSS (LIM_MAXRSS-1)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# endif /* LIM_MAXRSS */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# undef _lib_ulimit
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# ifdef _sys_vlimit
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# include <sys/vlimit.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# undef _lib_ulimit
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_FSIZE LIM_FSIZE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_DATA LIM_DATA
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_STACK LIM_STACK
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_CORE LIM_CORE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_CPU LIM_CPU
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# ifdef LIM_MAXRSS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_RSS LIM_MAXRSS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# endif /* LIM_MAXRSS */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# ifdef _lib_ulimit
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define vlimit ulimit
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# endif /* _lib_ulimit */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# endif /* _lib_vlimit */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef RLIM_INFINITY
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define INFINITY RLIM_INFINITY
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# ifndef INFINITY
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define INFINITY ((rlim_t)-1L)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# endif /* INFINITY */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif /* RLIM_INFINITY */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if defined(_lib_getrlimit) || defined(_lib_vlimit) || defined(_lib_ulimit)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# ifndef RLIMIT_CPU
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_CPU 0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# endif /* !RLIMIT_CPU */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# ifndef RLIMIT_DATA
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_DATA 0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# endif /* !RLIMIT_DATA */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# ifndef RLIMIT_RSS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_RSS 0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# endif /* !RLIMIT_RSS */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# ifndef RLIMIT_STACK
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_STACK 0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# endif /* !RLIMIT_STACK */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# ifndef RLIMIT_CORE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_CORE 0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# endif /* !RLIMIT_CORE */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# ifndef RLIMIT_VMEM
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_VMEM 0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# endif /* !RLIMIT_VMEM */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# ifndef RLIMIT_NOFILE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define RLIMIT_NOFILE 0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# endif /* !RLIMIT_NOFILE */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin# define _no_ulimit
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef _typ_rlim_t
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin typedef long rlim_t;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if !defined(RLIMIT_NOFILE) && defined(RLIMIT_OFILE)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_NOFILE RLIMIT_OFILE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RLIMIT_UNKNOWN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_UNKNOWN (-9999)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RLIMIT_AS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_AS RLIMIT_UNKNOWN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RLIMIT_CORE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_CORE RLIMIT_UNKNOWN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RLIMIT_CPU
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_CPU RLIMIT_UNKNOWN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RLIMIT_DATA
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_DATA RLIMIT_UNKNOWN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RLIMIT_FSIZE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_FSIZE RLIMIT_UNKNOWN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RLIMIT_LOCKS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_LOCKS RLIMIT_UNKNOWN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RLIMIT_MEMLOCK
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_MEMLOCK RLIMIT_UNKNOWN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RLIMIT_NOFILE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_NOFILE RLIMIT_UNKNOWN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RLIMIT_NPROC
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_NPROC RLIMIT_UNKNOWN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RLIMIT_PIPE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_PIPE RLIMIT_UNKNOWN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RLIMIT_RSS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_RSS RLIMIT_UNKNOWN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RLIMIT_SBSIZE
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_SBSIZE RLIMIT_UNKNOWN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RLIMIT_STACK
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_STACK RLIMIT_UNKNOWN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RLIMIT_PTHREAD
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_PTHREAD RLIMIT_UNKNOWN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef RLIMIT_VMEM
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define RLIMIT_VMEM RLIMIT_UNKNOWN
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define LIM_COUNT 0
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define LIM_BLOCK 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define LIM_BYTE 2
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define LIM_KBYTE 3
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define LIM_SECOND 4
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintypedef struct Limit_s
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin const char name[8];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin const char* description;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int index;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin const char* conf;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin unsigned char option;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin unsigned char type;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin} Limit_t;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const Limit_t shtab_limits[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const int shtab_units[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char e_unlimited[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern const char* e_units[];
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif /* _ULIMIT_H */