home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************
- *
- * $Source: /unixb/home/unixlib/source/unixlib37/src/resource/c/RCS/setrlimit,v $
- * $Date: 1996/05/06 09:03:13 $
- * $Revision: 1.2 $
- * $State: Rel $
- * $Author: unixlib $
- *
- * $Log: setrlimit,v $
- * Revision 1.2 1996/05/06 09:03:13 unixlib
- * Updates to sources made by Nick Burrett, Peter Burwood and Simon Callan.
- * Saved for 3.7a release.
- *
- * Revision 1.1 1996/04/19 21:29:28 simon
- * Initial revision
- *
- ***************************************************************************/
-
- static const char rcs_id[] = "$Id: setrlimit,v 1.2 1996/05/06 09:03:13 unixlib Rel $";
-
- #include <sys/resource.h>
- #include <sys/unix.h>
- #include <errno.h>
-
-
- /* Set the soft and hard limits for RESOURCE to *RLIMITS.
- Only the super-user can increase hard limits.
- Return 0 if successful, -1 if not (and sets errno). */
- int
- setrlimit (enum __rlimit_resource resource, struct rlimit *rlimits)
- {
- struct rlimit lim;
-
- if (rlimits == NULL || (unsigned int) resource >= RLIMIT_NLIMITS)
- {
- errno = EINVAL;
- return -1;
- }
-
- lim = *rlimits;
-
- #if 0
- if (lim.rlim_max != RLIM_INFINITY)
- {
- /* We have no enforceable resource limits. */
- errno = ENOSYS;
- return -1;
- }
- #endif
- if (lim.rlim_cur > lim.rlim_max)
- lim.rlim_cur = lim.rlim_max;
-
- __u->limit[resource] = lim;
-
- return 0;
- }
-