]> git.pld-linux.org Git - packages/bash.git/blobdiff - bash-rlimit_locks.patch
- typo, bash 2.05b BR readline 4.3 not 4.2
[packages/bash.git] / bash-rlimit_locks.patch
index 4ca94508b99238ee077b62e2d058ed1a366052d9..d48a10699426956349835f5d5257d198dd7886c5 100644 (file)
      -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.
- Otherwise, the current value of the specified resource is printed.
-@@ -202,6 +203,9 @@
+ 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)" },
+   { 'v',      RLIMIT_VIRTMEM, RLIMIT_VMBLKSZ, "virtual memory", "kbytes" },
  #endif
 +#ifdef RLIMIT_LOCKS
 +  { 'L',      RLIMIT_LOCKS,   1, "max file locks" },
 +#endif /* RLIMIT_LOCKS */
-   { -1, -1, -1, (char *)NULL }
- };
- #define NCMDS (sizeof(limits) / sizeof(limits[0]))
+ #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;
-   long block_factor;
-   RLIMTYPE current_limit, real_limit, limit;
+   int block_factor;
+   RLIMTYPE soft_limit, hard_limit, real_limit, limit;
  
-@@ -354,8 +359,15 @@
-   opt = get_limit (limind, mode, &current_limit);
+@@ -354,9 +359,20 @@
+   opt = get_limit (limind, &soft_limit, &hard_limit);
    if (opt < 0)
      {
--      builtin_error ("cannot get limit: %s", strerror (errno));
+-      builtin_error ("%s: cannot get limit: %s", limits[limind].description,
+-                                               strerror (errno));
 -      return (EXECUTION_FAILURE);
-+      if ( ( errno == 22 ) &&
-+         ( limits[limind].parameter == RLIMIT_LOCKS )
-+       ) {
-+      current_limit=RLIM_INFINITY;
-+      dont_locks = 1;
-+      } else {
-+            builtin_error ("cannot get limit: %s", 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, current_limit, multiple);
+       printone (limind, (mode & LIMIT_SOFT) ? soft_limit : hard_limit, multiple);
        return (EXECUTION_SUCCESS);
      }
 +
 +      return (EXECUTION_FAILURE);
 +    }
   
-   /* Setting the limit. */
-   if (STREQ (cmdarg, "unlimited"))
-@@ -617,8 +635,15 @@
+   /* Setting the limit. 
+   if (STREQ (cmdarg, "hard"))
+@@ -617,8 +635,18 @@
+   for (i = 0; limits[i].option > 0; i++)
      {
-       if (get_limit (i, mode, &value) < 0)
-       {
--        fprintf (stderr, DESCFMT, limits[i].description);
--        builtin_error ("cannot get limit: %s", strerror (errno));
-+                if ( ( errno == 22 ) &&
-+               ( limits[i].parameter == RLIMIT_LOCKS )
-+             ) {
-+              value=RLIM_INFINITY;
-+              printone (i, value, 1);
-+        } else {
-+          fprintf (stderr, DESCFMT, limits[i].description);
-+          builtin_error ("cannot get limit: %s", strerror (errno));
-+          }
-       }
+       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, value, 1);     
+       printone (i, (mode & LIMIT_SOFT) ? softlim : hardlim, 1);
This page took 0.032349 seconds and 4 git commands to generate.