Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] find RLIM_NLIMITS correctly on Cygwin



reply 1/2 to workers/45590⁩
> 2020/03/21 4:18, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> 
> Continuing my review:
> 
> Jun T wrote on Tue, 25 Feb 2020 18:38 +0900:
>> 
>> -END {
>> -    if (limrev["MEMLOCK"] != "") {
>> -        irss = limrev["RSS"]
>> -        msg[irss] = "Mmemoryuse"
>> -    }  
> 
> Question.  I compared the output before and after the patch and I see
> the following difference:
> 
>    % diff -U0 =(zsh-5.7.1 -fc 'limit') =(limit)
>    --- /tmp/zshZXxkUD      2020-03-20 18:00:04.239999929 +0000
>    +++ /tmp/zshxTTscg      2020-03-20 18:00:04.239999929 +0000
>    @@ -6 +6 @@
>    -memoryuse       unlimited
>    +resident        unlimited
>    zsh: exit 1     diff -U0 =(zsh-5.7.1 -fc 'limit') =(limit)
> 
> It seems to be caused by the C implementation not having an equivalent
> of the above piece of code. this difference intentional?

Sorry, I just lazily ignored that part of rlimits.awk because:
I didn't understand why existence of RLIMIT_MEMLOCK affects the name
of RLIMIT_RSS, and,
on Linux ulimit prints it as "resident set size", and,
RLIMIT_RSS is used only in kernel 2.4.29 or earlier (on Linux).

# bash's builtin ulimit prints it as "max memory size" on Linux.

If compatibility with the previous version of zsh is important
we may use the patch below.

zshbuiltin man page also needs be updated. Do we need to list all the
known resources? Or just list most common resources and mention that,
for example, exact list of resources supported on your system can
be shown by running 'limit' or 'ulimit -a'?


diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c
index aa9b9dd48..8f1d4b306 100644
--- a/Src/Builtins/rlimits.c
+++ b/Src/Builtins/rlimits.c
@@ -65,18 +65,23 @@ static const resinfo_T known_resources[] = {
     {RLIMIT_NOFILE, "descriptors", ZLIMTYPE_NUMBER, 1,
 		'n', "file descriptors"},
 # endif
+# ifdef HAVE_RLIMIT_MEMLOCK
+#  define RSS_NAME "memoryuse"
+# else
+#  define RSS_NAME "resident"
+# endif
 # if defined(HAVE_RLIMIT_AS) && !defined(RLIMIT_VMEM_IS_AS)
     {RLIMIT_AS, "addressspace", ZLIMTYPE_MEMORY, 1024,
 		'v', "address space (kbytes)"},
 # endif
 # if defined(HAVE_RLIMIT_RSS) && !defined(RLIMIT_VMEM_IS_RSS) && !defined(RLIMIT_RSS_IS_AS)
-    {RLIMIT_RSS, "resident", ZLIMTYPE_MEMORY, 1024,
+    {RLIMIT_RSS, RSS_NAME, ZLIMTYPE_MEMORY, 1024,
 		'm', "resident set size (kbytes)"},
 # endif
 # if defined(HAVE_RLIMIT_VMEM)
     {RLIMIT_VMEM,
 #  if defined(RLIMIT_VMEM_IS_RSS)
-		 "resident", ZLIMTYPE_MEMORY, 1024,
+		 RSS_NAME, ZLIMTYPE_MEMORY, 1024,
 		 'm', "memory size (kbytes)"
 #  else
 		 "vmemorysize", ZLIMTYPE_MEMORY, 1024,










Messages sorted by: Reverse Date, Date, Thread, Author