mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-26 16:40:29 +01:00
zsh-workers/8320
This commit is contained in:
parent
910dc80a58
commit
9411b0e51a
4 changed files with 69 additions and 65 deletions
|
|
@ -511,21 +511,22 @@ If no var(resource) is given, print all limits.
|
|||
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.)
|
||||
sitem(tt(sbsize))(Maximum size of all socket buffers.)
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
#
|
||||
BEGIN {limidx = 0}
|
||||
|
||||
/^[\t ]*(#[\t ]*define[\t _]*RLIMIT_[A-Z_]*[\t ]*[0-9][0-9]*|RLIMIT_[A-Z]*,[\t ]*)/ {
|
||||
/^[\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,22 +22,22 @@ BEGIN {limidx = 0}
|
|||
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" }
|
||||
if (limnam == "SBSIZE") { msg[limnum] = "sbsize" }
|
||||
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" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -55,21 +55,33 @@ BEGIN {limidx = 0}
|
|||
END {
|
||||
if (limrev["MEMLOCK"] != "") {
|
||||
irss = limrev["RSS"]
|
||||
msg[irss] = "memoryuse"
|
||||
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 *recs[ZSH_NLIMITS+1] = {\n", 0 + nlimits)
|
||||
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] == "") {
|
||||
badlimit++
|
||||
if (msg[i] == "")
|
||||
printf("\t%c%s%c,\n", 34, lim[i], 34)
|
||||
} else
|
||||
printf("\t%c%s%c,\n", 34, msg[i], 34)
|
||||
print "\tNULL"
|
||||
else
|
||||
printf("\t%c%s%c,\n", 34, substr(msg[i], 2, 30), 34)
|
||||
print "};"
|
||||
print ""
|
||||
exit(badlimit)
|
||||
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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,13 @@
|
|||
|
||||
#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,22 +92,15 @@ showlimits(int hard, int lim)
|
|||
val = (hard) ? limits[rt].rlim_max : limits[rt].rlim_cur;
|
||||
if (val == RLIM_INFINITY)
|
||||
printf("unlimited\n");
|
||||
else if (rt==RLIMIT_CPU)
|
||||
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));
|
||||
# ifdef RLIMIT_NPROC
|
||||
else if (rt == RLIMIT_NPROC)
|
||||
} else if (limtype[rt] == ZLIMTYPE_NUMBER || limtype[rt] == ZLIMTYPE_UNKNOWN) {
|
||||
/* 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)
|
||||
} 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,7 +297,7 @@ bin_limit(char *nam, char **argv, char *ops, int func)
|
|||
showlimits(hard, lim);
|
||||
return 0;
|
||||
}
|
||||
if (lim==RLIMIT_CPU) {
|
||||
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,20 +315,11 @@ bin_limit(char *nam, char **argv, char *ops, int func)
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
# ifdef RLIMIT_NPROC
|
||||
else if (lim == RLIMIT_NPROC)
|
||||
} 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);
|
||||
# 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 {
|
||||
} else {
|
||||
/* memory-type resource -- `k' and `M' modifiers are permitted,
|
||||
meaning (respectively) 2^10 and 2^20. */
|
||||
val = zstrtorlimt(s, &s, 10);
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ objects="rlimits.o"
|
|||
:<<\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
|
||||
# this file will not be made if limits are unavailable
|
||||
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
|
||||
$(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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue