From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3169 invoked by alias); 5 Jan 2010 16:24:35 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 27566 Received: (qmail 517 invoked from network); 5 Jan 2010 16:24:23 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=ham version=3.2.5 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Tue, 5 Jan 2010 16:24:12 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: "ulimit -c junk" silently treated as "ulimit -c 0" Message-ID: <20100105162412.2afe4254@news01> In-Reply-To: <87k4w0gm7b.fsf@Astalo.kon.iki.fi> References: <87k4w0gm7b.fsf@Astalo.kon.iki.fi> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 05 Jan 2010 16:24:12.0342 (UTC) FILETIME=[84054D60:01CA8E23] X-Scanned-By: MailControl A-09-22-10 (www.mailcontrol.com) on 10.68.0.121 On Sun, 03 Jan 2010 00:45:44 +0200 Kalle Olavi Niemitalo wrote: > When I switched from bash to zsh, I copied this to my .zprofile: > > ulimit -c hard > > In bash, it sets the soft limit of core dump size to be the same > as the hard limit. This isn't very hard, either. I see also that the documentation specifies that argument errors cause processing to abort immediately. Index: Doc/Zsh/builtins.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v retrieving revision 1.128 diff -u -r1.128 builtins.yo --- Doc/Zsh/builtins.yo 19 Sep 2009 16:29:16 -0000 1.128 +++ Doc/Zsh/builtins.yo 5 Jan 2010 16:20:18 -0000 @@ -1710,13 +1710,18 @@ item(tt(ulimit) [ [ tt(-SHacdfilmnpqstvx) | tt(-N) var(resource) [ var(limit) ] ... ])( Set or display resource limits of the shell and the processes started by the shell. The value of var(limit) can be a number in the unit specified -below or the value `tt(unlimited)'. By default, only soft limits are -manipulated. If the tt(-H) flag is given use -hard limits instead of soft limits. If the tt(-S) flag is given -together with the tt(-H) flag set both hard and soft limits. If no -options are used, the file size limit (tt(-f)) is assumed. If -var(limit) is omitted the current value of the specified resources are -printed. When more than one resource values are printed the limit name and +below or one of the values `tt(unlimited)', which removes the limit on the +resource, or `tt(hard)', which uses the current value of the hard limit on +the resource. + +By default, only soft limits are manipulated. If the tt(-H) flag +is given use hard limits instead of soft limits. If the tt(-S) flag is given +together with the tt(-H) flag set both hard and soft limits. + +If no options are used, the file size limit (tt(-f)) is assumed. + +If var(limit) is omitted the current value of the specified resources are +printed. When more than one resource value is printed, the limit name and unit is printed before each value. When looping over multiple resources, the shell will abort immediately if Index: Src/Builtins/rlimits.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Builtins/rlimits.c,v retrieving revision 1.21 diff -u -r1.21 rlimits.c --- Src/Builtins/rlimits.c 5 Jan 2010 15:58:20 -0000 1.21 +++ Src/Builtins/rlimits.c 5 Jan 2010 16:20:18 -0000 @@ -836,11 +836,24 @@ /* 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 @@ 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++; -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom