--- bash-2.04.old/builtins/ulimit.def Mon Jan 24 13:47:38 2000 +++ bash-2.04/builtins/ulimit.def Mon Apr 16 17:39:19 2001 @@ -24,7 +24,7 @@ $BUILTIN ulimit $FUNCTION ulimit_builtin $DEPENDS_ON !_MINIX -$SHORT_DOC ulimit [-SHacdflmnpstuv] [limit] +$SHORT_DOC ulimit [-SHacdflmnpstuvL] [limit] Ulimit provides control over the resources available to processes started by the shell, on systems that allow such control. If an option is given, it is interpreted as follows: @@ -43,6 +43,7 @@ -t the maximum amount of cpu time in seconds -u the maximum number of user processes -v the size of virtual memory + -L the maximum number of file locks (Kernel >= 2.4) If LIMIT is given, it is the new value of the specified resource; the special LIMIT values `soft', `hard', and `unlimited' stand for @@ -216,6 +216,9 @@ #if defined (HAVE_RESOURCE) { 'v', RLIMIT_VIRTMEM, RLIMIT_VMBLKSZ, "virtual memory", "kbytes" }, #endif +#ifdef RLIMIT_LOCKS + { 'L', RLIMIT_LOCKS, 1, "max file locks" }, +#endif /* RLIMIT_LOCKS */ #ifdef RLIMIT_SWAP { 'w', RLIMIT_SWAP, 1024, "swap size", "kbytes" }, #endif @@ -344,6 +348,7 @@ int mode, multiple; { int opt, limind, setting; + int dont_locks = 0; int block_factor; RLIMTYPE soft_limit, hard_limit, real_limit, limit; @@ -354,9 +359,20 @@ opt = get_limit (limind, &soft_limit, &hard_limit); if (opt < 0) { - builtin_error (_("%s: cannot get limit: %s"), limits[limind].description, - strerror (errno)); - return (EXECUTION_FAILURE); + if (( errno == 22) && (limits[limind].parameter == RLIMIT_LOCKS)) + { + if (mode & LIMIT_SOFT) + soft_limit = RLIM_INFINITY; + else + hard_limit = RLIM_INFINITY; + dont_locks = 1; + } + else + { + builtin_error (_("%s: cannot get limit: %s"), limits[limind].description, + strerror (errno)); + return (EXECUTION_FAILURE); + } } if (setting == 0) /* print the value of the specified limit */ @@ -363,6 +375,12 @@ printone (limind, (mode & LIMIT_SOFT) ? soft_limit : hard_limit, multiple); return (EXECUTION_SUCCESS); } + + if (dont_locks) + { + builtin_error (_("cannot set it on the current kernel")); + return (EXECUTION_FAILURE); + } /* Setting the limit. if (STREQ (cmdarg, "hard")) @@ -617,8 +635,18 @@ for (i = 0; limits[i].option > 0; i++) { if (get_limit (i, &softlim, &hardlim) < 0) - builtin_error ("%s: cannot get limit: %s", limits[i].description, - strerror (errno)); + { + if ((errno == 22) && (limits[i].parameter == RLIMIT_LOCKS)) + { + if (mode & LIMIT_SOFT) + softlim = RLIM_INFINITY; + else + hardlim = RLIM_INFINITY; + printone (i, (mode & LIMIT_SOFT) ? softlim : hardlim, 1); + } else + builtin_error ("%s: cannot get limit: %s", limits[i].description, + strerror (errno)); + } else printone (i, (mode & LIMIT_SOFT) ? softlim : hardlim, 1);