summary refs log tree commit diff
path: root/Src/Builtins
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-01-05 16:29:35 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-01-05 16:29:35 +0000
commitf80bc2b5f6dc4c6aa58da88e075a588988807afb (patch)
tree2d099887392d0746cd5c3c880c60aec0517fa209 /Src/Builtins
parentde4dac88749fbfefe7b78b0d747893c28c414abb (diff)
downloadzsh-f80bc2b5f6dc4c6aa58da88e075a588988807afb.tar.gz
zsh-f80bc2b5f6dc4c6aa58da88e075a588988807afb.tar.xz
zsh-f80bc2b5f6dc4c6aa58da88e075a588988807afb.zip
27566: add ulimit -c hard and immediate return on argument error
Diffstat (limited to 'Src/Builtins')
-rw-r--r--Src/Builtins/rlimits.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c
index 8843fb1db..7ee0de012 100644
--- a/Src/Builtins/rlimits.c
+++ b/Src/Builtins/rlimits.c
@@ -836,11 +836,24 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 	    /* set limit to specified value */
 	    rlim_t limit;
 
-	    limit = zstrtorlimt(*argv, &eptr, 10);
-	    if (*eptr) {
-		zwarnnam(name, "invalid number: %s", *argv);
-		ret++;
+	    if (!strcmp(*argv, "hard")) {
+		struct rlimit vals;
+
+		if (getrlimit(res, &vals) < 0)
+		{
+		    zwarnnam(name, "can't read limit: %e", errno);
+		    return 1;
+		}
+		else
+		{
+		    limit = vals.rlim_max;
+		}
 	    } else {
+		limit = zstrtorlimt(*argv, &eptr, 10);
+		if (*eptr) {
+		    zwarnnam(name, "invalid number: %s", *argv);
+		    return 1;
+		}
 		/* scale appropriately */
 		switch (res) {
 		case RLIMIT_FSIZE:
@@ -870,9 +883,9 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 		    limit *= 1024;
 		    break;
 		}
-		if (do_limit(name, res, limit, hard, soft, 1))
-		    ret++;
 	    }
+	    if (do_limit(name, res, limit, hard, soft, 1))
+		ret++;
 	} else {
 	    if (do_unlimit(name, res, hard, soft, 1, geteuid()))
 		ret++;