From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8847 invoked from network); 18 Oct 1999 10:17:01 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 18 Oct 1999 10:17:01 -0000 Received: (qmail 436 invoked by alias); 18 Oct 1999 10:16:51 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8320 Received: (qmail 428 invoked from network); 18 Oct 1999 10:16:51 -0000 Subject: Re: About to release 3.0.7 ... In-Reply-To: <19991018014649.A84537@hal.mpn.cp.philips.com> from Jos Backus at "Oct 18, 1999 1:46:49 am" To: Jos.Backus@nl.origin-it.com Date: Mon, 18 Oct 1999 11:16:43 +0100 (BST) Cc: schaefer@candle.brasslantern.com, zsh-workers@sunsite.auc.dk X-Mailer: ELM [version 2.4ME+ PL48 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: From: Zefram Jos Backus wrote: >+ if (limnam == "SBSIZE") { msg[limnum] = "sbsize" } This is not a good name. zsh's resource limit names tend to be more verbose, so you don't need to know the system to see what is being limited. I suggest the name "sktbuffersize". Two more general resource limit issues: 1. It should be possible to distinguish between there being unknown limits (a non-fatal condition) and genuine errors in running rlimits.awk. 2. Some limits aren't being handled the right way (memory type limits vs pure numeric vs time spans). It's currently excessively awkward to get them right; we need a more general mechanism. Here's a patch fixing these problems and making a couple of other minor cleanups. This is against an unpatched 3.1.6-bart-7. -zefram diff -cr ../zsh-3.1.6-bart-7.old/Doc/Zsh/builtins.yo ./Doc/Zsh/builtins.yo *** ../zsh-3.1.6-bart-7.old/Doc/Zsh/builtins.yo Thu Oct 14 04:21:54 1999 --- ./Doc/Zsh/builtins.yo Mon Oct 18 10:03:47 1999 *************** *** 511,530 **** var(resource) can be one of: startsitem() ! sitem(tt(memorylocked))(Maximum amount of memory locked in RAM.) ! sitem(tt(resident))(Maximum resident set size.) ! sitem(tt(vmemorysize))(Maximum amount of virtual memory.) ! sitem(tt(descriptors))(Maximum value for a file descriptor.) sitem(tt(coredumpsize))(Maximum size of a core dump.) ! sitem(tt(stacksize))(Maximum stack size for each process.) sitem(tt(datasize))(Maximum data size (including stack) for each process.) sitem(tt(filesize))(Largest single file allowed.) - sitem(tt(cputime))(Maximum CPU seconds per process.) sitem(tt(maxproc))(Maximum number of processes.) ! sitem(tt(addressspace))(Maximum amount of address space used.) ! sitem(tt(cachedthreads))(Maximum number of cached threads.) ! sitem(tt(aiooperations))(Maximum number of AIO operations.) ! sitem(tt(aiomemorylocked))(Maximum amount of memory locked in RAM for AIO operations.) endsitem() Which of these resource limits are available depends on the system. --- 511,532 ---- var(resource) can be one of: startsitem() ! sitem(tt(addressspace))(Maximum amount of address space used.) ! sitem(tt(aiomemorylocked))(Maximum amount of memory locked in RAM for AIO operations.) ! sitem(tt(aiooperations))(Maximum number of AIO operations.) ! sitem(tt(cachedthreads))(Maximum number of cached threads.) sitem(tt(coredumpsize))(Maximum size of a core dump.) ! sitem(tt(cputime))(Maximum CPU seconds per process.) sitem(tt(datasize))(Maximum data size (including stack) for each process.) + sitem(tt(descriptors))(Maximum value for a file descriptor.) sitem(tt(filesize))(Largest single file allowed.) sitem(tt(maxproc))(Maximum number of processes.) ! sitem(tt(memorylocked))(Maximum amount of memory locked in RAM.) ! sitem(tt(memoryuse))(Maximum resident set size.) ! sitem(tt(resident))(Maximum resident set size.) ! sitem(tt(sktbuffersize))(Maximum size of all socket buffers.) ! sitem(tt(stacksize))(Maximum stack size for each process.) ! sitem(tt(vmemorysize))(Maximum amount of virtual memory.) endsitem() Which of these resource limits are available depends on the system. diff -cr ../zsh-3.1.6-bart-7.old/Src/Builtins/rlimits.awk ./Src/Builtins/rlimits.awk *** ../zsh-3.1.6-bart-7.old/Src/Builtins/rlimits.awk Thu Oct 14 04:21:55 1999 --- ./Src/Builtins/rlimits.awk Mon Oct 18 10:56:52 1999 *************** *** 6,12 **** # BEGIN {limidx = 0} ! /^[\t ]*(#[\t ]*define[\t _]*RLIMIT_[A-Z_]*[\t ]*[0-9][0-9]*|RLIMIT_[A-Z]*,[\t ]*)/ { limindex = index($0, "RLIMIT_") limtail = substr($0, limindex, 80) split(limtail, tmp) --- 6,12 ---- # BEGIN {limidx = 0} ! /^[\t ]*(#[\t ]*define[\t _]*RLIMIT_[A-Z_]*[\t ]*[0-9][0-9]*|RLIMIT_[A-Z_]*,[\t ]*)/ { limindex = index($0, "RLIMIT_") limtail = substr($0, limindex, 80) split(limtail, tmp) *************** *** 22,42 **** if (lim[limnum] == "") { lim[limnum] = limnam if (limnum ~ /^[0-9]*$/) { ! if (limnam == "MEMLOCK") { msg[limnum] = "memorylocked" } ! if (limnam == "RSS") { msg[limnum] = "resident" } ! if (limnam == "VMEM") { msg[limnum] = "vmemorysize" } ! if (limnam == "NOFILE") { msg[limnum] = "descriptors" } ! if (limnam == "OFILE") { msg[limnum] = "descriptors" } ! if (limnam == "CORE") { msg[limnum] = "coredumpsize" } ! if (limnam == "STACK") { msg[limnum] = "stacksize" } ! if (limnam == "DATA") { msg[limnum] = "datasize" } ! if (limnam == "FSIZE") { msg[limnum] = "filesize" } ! if (limnam == "CPU") { msg[limnum] = "cputime" } ! if (limnam == "NPROC") { msg[limnum] = "maxproc" } ! if (limnam == "AS") { msg[limnum] = "addressspace" } ! if (limnam == "TCACHE") { msg[limnum] = "cachedthreads" } ! if (limnam == "AIO_OPS") { msg[limnum] = "aiooperations" } ! if (limnam == "AIO_MEM") { msg[limnum] = "aiomemorylocked" } } } } --- 22,43 ---- if (lim[limnum] == "") { lim[limnum] = limnam if (limnum ~ /^[0-9]*$/) { ! if (limnam == "AIO_MEM") { msg[limnum] = "Maiomemorylocked" } ! if (limnam == "AIO_OPS") { msg[limnum] = "Naiooperations" } ! if (limnam == "AS") { msg[limnum] = "Maddressspace" } ! if (limnam == "CORE") { msg[limnum] = "Mcoredumpsize" } ! if (limnam == "CPU") { msg[limnum] = "Tcputime" } ! if (limnam == "DATA") { msg[limnum] = "Mdatasize" } ! if (limnam == "FSIZE") { msg[limnum] = "Mfilesize" } ! if (limnam == "MEMLOCK") { msg[limnum] = "Mmemorylocked" } ! if (limnam == "NOFILE") { msg[limnum] = "Ndescriptors" } ! if (limnam == "NPROC") { msg[limnum] = "Nmaxproc" } ! if (limnam == "OFILE") { msg[limnum] = "Ndescriptors" } ! if (limnam == "RSS") { msg[limnum] = "Mresident" } ! if (limnam == "SBSIZE") { msg[limnum] = "Msktbuffersize" } ! if (limnam == "STACK") { msg[limnum] = "Mstacksize" } ! if (limnam == "TCACHE") { msg[limnum] = "Ncachedthreads" } ! if (limnam == "VMEM") { msg[limnum] = "Mvmemorysize" } } } } *************** *** 54,74 **** END { if (limrev["MEMLOCK"] != "") { irss = limrev["RSS"] ! msg[irss] = "memoryuse" } ps = "%s" printf("%s\n%s\n\n", "/** rlimits.h **/", "/** architecture-customized limits for zsh **/") ! printf("#define ZSH_NLIMITS %d\n\nstatic char *recs[ZSH_NLIMITS+1] = {\n", 0 + nlimits) for (i = 0; i < 0 + nlimits; i++) ! if (msg[i] == "") { ! badlimit++ printf("\t%c%s%c,\n", 34, lim[i], 34) ! } else ! printf("\t%c%s%c,\n", 34, msg[i], 34) ! print "\tNULL" print "};" print "" ! exit(badlimit) } --- 55,87 ---- END { if (limrev["MEMLOCK"] != "") { irss = limrev["RSS"] ! msg[irss] = "Mmemoryuse" } ps = "%s" printf("%s\n%s\n\n", "/** rlimits.h **/", "/** architecture-customized limits for zsh **/") ! printf("#define ZSH_NLIMITS %d\n\nstatic char const *recs[ZSH_NLIMITS] = {\n", 0 + nlimits) for (i = 0; i < 0 + nlimits; i++) ! if (msg[i] == "") printf("\t%c%s%c,\n", 34, lim[i], 34) ! else ! printf("\t%c%s%c,\n", 34, substr(msg[i], 2, 30), 34) print "};" print "" ! print "static int limtype[ZSH_NLIMITS] = {" ! for (i = 0; i < 0 + nlimits; i++) { ! if (msg[i] == "") ! limtype = "UNKNOWN" ! else { ! limtype = substr(msg[i], 1, 1) ! if(limtype == "M") { limtype = "MEMORY" } ! if(limtype == "N") { limtype = "NUMBER" } ! if(limtype == "T") { limtype = "TIME" } ! } ! printf("\tZLIMTYPE_%s,\n", limtype) ! } ! print "};" ! ! exit(0) } diff -cr ../zsh-3.1.6-bart-7.old/Src/Builtins/rlimits.c ./Src/Builtins/rlimits.c *** ../zsh-3.1.6-bart-7.old/Src/Builtins/rlimits.c Thu Oct 14 04:21:55 1999 --- ./Src/Builtins/rlimits.c Mon Oct 18 10:15:52 1999 *************** *** 32,37 **** --- 32,44 ---- #if defined(HAVE_GETRLIMIT) && defined(RLIM_INFINITY) + enum { + ZLIMTYPE_MEMORY, + ZLIMTYPE_NUMBER, + ZLIMTYPE_TIME, + ZLIMTYPE_UNKNOWN + }; + /* Generated rec array containing limits required for the limit builtin. * * They must appear in this array in numerical order of the RLIMIT_* macros. */ *************** *** 85,106 **** val = (hard) ? limits[rt].rlim_max : limits[rt].rlim_cur; if (val == RLIM_INFINITY) printf("unlimited\n"); ! else if (rt==RLIMIT_CPU) /* time-type resource -- display as hours, minutes and seconds. */ printf("%d:%02d:%02d\n", (int)(val / 3600), (int)(val / 60) % 60, (int)(val % 60)); ! # ifdef RLIMIT_NPROC ! else if (rt == RLIMIT_NPROC) ! /* pure numeric resource */ ! printf("%d\n", (int)val); ! # endif /* RLIMIT_NPROC */ ! # ifdef RLIMIT_NOFILE ! else if (rt == RLIMIT_NOFILE) /* pure numeric resource */ printf("%d\n", (int)val); ! # endif /* RLIMIT_NOFILE */ ! else if (val >= 1024L * 1024L) /* memory resource -- display with `K' or `M' modifier */ # ifdef RLIM_T_IS_QUAD_T printf("%qdMB\n", val / (1024L * 1024L)); --- 92,106 ---- val = (hard) ? limits[rt].rlim_max : limits[rt].rlim_cur; if (val == RLIM_INFINITY) printf("unlimited\n"); ! else if (limtype[rt] == ZLIMTYPE_TIME) { /* time-type resource -- display as hours, minutes and seconds. */ printf("%d:%02d:%02d\n", (int)(val / 3600), (int)(val / 60) % 60, (int)(val % 60)); ! } else if (limtype[rt] == ZLIMTYPE_NUMBER || limtype[rt] == ZLIMTYPE_UNKNOWN) { /* pure numeric resource */ printf("%d\n", (int)val); ! } else if (val >= 1024L * 1024L) /* memory resource -- display with `K' or `M' modifier */ # ifdef RLIM_T_IS_QUAD_T printf("%qdMB\n", val / (1024L * 1024L)); *************** *** 297,303 **** showlimits(hard, lim); return 0; } ! if (lim==RLIMIT_CPU) { /* time-type resource -- may be specified as seconds, or minutes or * * hours with the `m' and `h' modifiers, and `:' may be used to add * * together more than one of these. It's easier to understand from * --- 297,303 ---- showlimits(hard, lim); return 0; } ! if (limtype[lim] == ZLIMTYPE_TIME) { /* time-type resource -- may be specified as seconds, or minutes or * * hours with the `m' and `h' modifiers, and `:' may be used to add * * together more than one of these. It's easier to understand from * *************** *** 315,334 **** return 1; } } ! } ! # ifdef RLIMIT_NPROC ! else if (lim == RLIMIT_NPROC) /* pure numeric resource -- only a straight decimal number is permitted. */ val = zstrtorlimt(s, &s, 10); ! # endif /* RLIMIT_NPROC */ ! # ifdef RLIMIT_NOFILE ! else if (lim == RLIMIT_NOFILE) ! /* pure numeric resource -- only a straight decimal number is ! permitted. */ ! val = zstrtorlimt(s, &s, 10); ! # endif /* RLIMIT_NOFILE */ ! else { /* memory-type resource -- `k' and `M' modifiers are permitted, meaning (respectively) 2^10 and 2^20. */ val = zstrtorlimt(s, &s, 10); --- 315,325 ---- return 1; } } ! } else if (limtype[lim] == ZLIMTYPE_NUMBER || limtype[lim] == ZLIMTYPE_UNKNOWN) { /* pure numeric resource -- only a straight decimal number is permitted. */ val = zstrtorlimt(s, &s, 10); ! } else { /* memory-type resource -- `k' and `M' modifiers are permitted, meaning (respectively) 2^10 and 2^20. */ val = zstrtorlimt(s, &s, 10); Only in ./Src/Builtins: rlimits.h diff -cr ../zsh-3.1.6-bart-7.old/Src/Builtins/rlimits.mdd ./Src/Builtins/rlimits.mdd *** ../zsh-3.1.6-bart-7.old/Src/Builtins/rlimits.mdd Mon Jun 1 18:08:45 1998 --- ./Src/Builtins/rlimits.mdd Mon Oct 18 10:31:00 1999 *************** *** 5,16 **** :<<\Make rlimits.o rlimits..o: rlimits.h ! # this file will not be made if limits are unavailable: ! # silent so the warning doesn't appear unless necessary rlimits.h: rlimits.awk @RLIMITS_INC_H@ ! @echo '$(AWK) -f $(sdir)/rlimits.awk @RLIMITS_INC_H@ > rlimits.h'; \ ! $(AWK) -f $(sdir)/rlimits.awk @RLIMITS_INC_H@ > rlimits.h || \ ! echo WARNING: unknown limits: mail rlimits.h to developers clean-here: clean.rlimits clean.rlimits: --- 5,16 ---- :<<\Make rlimits.o rlimits..o: rlimits.h ! # this file will not be made if limits are unavailable rlimits.h: rlimits.awk @RLIMITS_INC_H@ ! $(AWK) -f $(sdir)/rlimits.awk @RLIMITS_INC_H@ > rlimits.h ! @if grep ZLIMTYPE_UNKNOWN rlimits.h >/dev/null; then \ ! echo >&2 WARNING: unknown limits: mail rlimits.h to developers; \ ! else :; fi clean-here: clean.rlimits clean.rlimits: END