]>
Commit | Line | Data |
---|---|---|
1 | --- bash-2.04.old/builtins/ulimit.def Mon Jan 24 13:47:38 2000 | |
2 | +++ bash-2.04/builtins/ulimit.def Mon Apr 16 17:39:19 2001 | |
3 | @@ -24,7 +24,7 @@ | |
4 | $BUILTIN ulimit | |
5 | $FUNCTION ulimit_builtin | |
6 | $DEPENDS_ON !_MINIX | |
7 | -$SHORT_DOC ulimit [-SHacdflmnpstuv] [limit] | |
8 | +$SHORT_DOC ulimit [-SHacdflmnpstuvL] [limit] | |
9 | Ulimit provides control over the resources available to processes | |
10 | started by the shell, on systems that allow such control. If an | |
11 | option is given, it is interpreted as follows: | |
12 | @@ -43,6 +43,7 @@ | |
13 | -t the maximum amount of cpu time in seconds | |
14 | -u the maximum number of user processes | |
15 | -v the size of virtual memory | |
16 | + -L the maximum number of file locks (Kernel >= 2.4) | |
17 | ||
18 | If LIMIT is given, it is the new value of the specified resource; | |
19 | the special LIMIT values `soft', `hard', and `unlimited' stand for | |
20 | @@ -216,6 +216,9 @@ | |
21 | #if defined (HAVE_RESOURCE) | |
22 | { 'v', RLIMIT_VIRTMEM, RLIMIT_VMBLKSZ, "virtual memory", "kbytes" }, | |
23 | #endif | |
24 | +#ifdef RLIMIT_LOCKS | |
25 | + { 'L', RLIMIT_LOCKS, 1, "max file locks" }, | |
26 | +#endif /* RLIMIT_LOCKS */ | |
27 | #ifdef RLIMIT_SWAP | |
28 | { 'w', RLIMIT_SWAP, 1024, "swap size", "kbytes" }, | |
29 | #endif | |
30 | @@ -344,6 +348,7 @@ | |
31 | int mode, multiple; | |
32 | { | |
33 | int opt, limind, setting; | |
34 | + int dont_locks = 0; | |
35 | int block_factor; | |
36 | RLIMTYPE soft_limit, hard_limit, real_limit, limit; | |
37 | ||
38 | @@ -354,9 +359,20 @@ | |
39 | opt = get_limit (limind, &soft_limit, &hard_limit); | |
40 | if (opt < 0) | |
41 | { | |
42 | - builtin_error (_("%s: cannot get limit: %s"), limits[limind].description, | |
43 | - strerror (errno)); | |
44 | - return (EXECUTION_FAILURE); | |
45 | + if (( errno == 22) && (limits[limind].parameter == RLIMIT_LOCKS)) | |
46 | + { | |
47 | + if (mode & LIMIT_SOFT) | |
48 | + soft_limit = RLIM_INFINITY; | |
49 | + else | |
50 | + hard_limit = RLIM_INFINITY; | |
51 | + dont_locks = 1; | |
52 | + } | |
53 | + else | |
54 | + { | |
55 | + builtin_error (_("%s: cannot get limit: %s"), limits[limind].description, | |
56 | + strerror (errno)); | |
57 | + return (EXECUTION_FAILURE); | |
58 | + } | |
59 | } | |
60 | ||
61 | if (setting == 0) /* print the value of the specified limit */ | |
62 | @@ -363,6 +375,12 @@ | |
63 | printone (limind, (mode & LIMIT_SOFT) ? soft_limit : hard_limit, multiple); | |
64 | return (EXECUTION_SUCCESS); | |
65 | } | |
66 | + | |
67 | + if (dont_locks) | |
68 | + { | |
69 | + builtin_error (_("cannot set it on the current kernel")); | |
70 | + return (EXECUTION_FAILURE); | |
71 | + } | |
72 | ||
73 | /* Setting the limit. | |
74 | if (STREQ (cmdarg, "hard")) | |
75 | @@ -617,8 +635,18 @@ | |
76 | for (i = 0; limits[i].option > 0; i++) | |
77 | { | |
78 | if (get_limit (i, &softlim, &hardlim) < 0) | |
79 | - builtin_error ("%s: cannot get limit: %s", limits[i].description, | |
80 | - strerror (errno)); | |
81 | + { | |
82 | + if ((errno == 22) && (limits[i].parameter == RLIMIT_LOCKS)) | |
83 | + { | |
84 | + if (mode & LIMIT_SOFT) | |
85 | + softlim = RLIM_INFINITY; | |
86 | + else | |
87 | + hardlim = RLIM_INFINITY; | |
88 | + printone (i, (mode & LIMIT_SOFT) ? softlim : hardlim, 1); | |
89 | + } else | |
90 | + builtin_error ("%s: cannot get limit: %s", limits[i].description, | |
91 | + strerror (errno)); | |
92 | + } | |
93 | else | |
94 | printone (i, (mode & LIMIT_SOFT) ? softlim : hardlim, 1); | |
95 |