Bug 15565 - ulimit -v does not work
ulimit -v does not work
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: bash (Show other bugs)
6.2
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Bernhard Rosenkraenzer
: Security
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-08-06 11:22 EDT by Thimo E
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-08-06 11:22:15 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Thimo E 2000-08-06 11:22:12 EDT
in bash1 the function ulimit -v <size> (limit the size of virtual memory) does not work (is :

ulimit: cannot raise limit: Invalid argument

(and the query with ulimit -v doesn't work correctly, too)

Here is a quick  (and certainly dirty) patch, I've wrote:

--- builtins/ulimit.def.orig    Sun Jul 30 19:53:35 2000
+++ builtins/ulimit.def Sun Jul 30 23:14:53 2000
@@ -91,6 +91,19 @@

 static void print_long ();

+#ifdef RLIMIT_VMEM
+#  define RLIMIT_VIRTMEM        RLIMIT_VMEM
+#  define RLIMIT_VMBLKSZ        1024
+#else
+#  ifdef RLIMIT_AS
+#    define RLIMIT_VIRTMEM      RLIMIT_AS
+#    define RLIMIT_VMBLKSZ      1024
+#  else
+#    define RLIMIT_VIRTMEM      259
+#    define RLIMIT_VMBLKSZ      1
+#  endif
+#endif
+
 /* **************************************************************** */
 /*                                                                 */
 /*                     Ulimit builtin and Hacks.                   */
@@ -239,7 +252,7 @@

                case 'v':
                  ADD_CMD (u_MAX_VIRTUAL_MEM);
-                 block_factor = 1;
+                 block_factor = RLIMIT_VMBLKSZ;
                  break;

                case 'u':
@@ -519,8 +532,13 @@
     case u_MAX_VIRTUAL_MEM:
       if (setting)
        {
-         errno = EINVAL;
+#if defined (RLIMIT_VIRTMEM)
+         cmd = RLIMIT_VIRTMEM;
+         goto do_ulimit;
+#else
+          errno = EINVAL;
          return ((RLIMTYPE)-1);
+#endif /* !RLIMIT_VIRTMEM */
        }
       else
        {
@@ -553,13 +571,12 @@
      int mode;
 {
   struct rlimit rl;
+#if defined (RLIMIT_VIRTMEM)
+  if (getrlimit (RLIMIT_VIRTMEM, &rl) < 0)
+    return -1;
+  return (mode & LIMIT_SOFT) ? (rl.rlim_cur) : (rl.rlim_max);
+#else /* !RLIMIT_VIRTMEM */

-#if defined (RLIMIT_VMEM)
-  if (getrlimit (RLIMIT_VMEM, &rl) < 0)
-    return ((RLIMTYPE)-1);
-  else
-    return (((mode & LIMIT_SOFT) ? rl.rlim_cur : rl.rlim_max) / 1024L);
-#else /* !RLIMIT_VMEM */
   RLIMTYPE maxdata, maxstack;

   if (getrlimit (RLIMIT_DATA, &rl) < 0)
@@ -574,7 +591,7 @@

   /* Protect against overflow. */
   return ((maxdata / 1024L) + (maxstack / 1024L));
-#endif /* !RLIMIT_VMEM */
+#endif /* RLIMIT_VIRTMEM */
 }
 #endif /* HAVE_RESOURCE */

@@ -715,7 +732,7 @@
   if (cmd & u_MAX_VIRTUAL_MEM)
     {
       printf ("%-25s", "virtual memory (kbytes)");
-      print_rlimtype (getmaxvm (mode), 1);
+      print_rlimtype ((getmaxvm (mode) / RLIMIT_VMBLKSZ), 1);
     }
 #endif /* HAVE_RESOURCE */
 }
Comment 1 Bernhard Rosenkraenzer 2000-08-07 10:29:57 EDT
This has been fixed in rawhide for a couple of months.

Note You need to log in before you can comment on or make changes to this bug.