zsh-workers
 help / color / mirror / code / Atom feed
* ulimit behaviour of bash vs. zsh
@ 2014-10-06 12:30 Michael Prokop
  2014-10-06 13:23 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Prokop @ 2014-10-06 12:30 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 341 bytes --]

Hi,

this is what Bash does:

$ ulimit -l
64
$ ulimit -l unlimited
bash: ulimit: max locked memory: cannot modify limit: Operation not permitted
$ echo $?
1

While that's the behaviour of Zsh:

% ulimit -l
64
% ulimit -l unlimited
% echo $?
0
% ulimit -l
64

I find this quite irritating. Is that behaviour by intention? :)

regards,
-mika-

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ulimit behaviour of bash vs. zsh
  2014-10-06 12:30 ulimit behaviour of bash vs. zsh Michael Prokop
@ 2014-10-06 13:23 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2014-10-06 13:23 UTC (permalink / raw)
  To: zsh-workers

On Mon, 06 Oct 2014 14:30:46 +0200
Michael Prokop <news@michael-prokop.at> wrote:
> this is what Bash does:
> 
> $ ulimit -l
> 64
> $ ulimit -l unlimited
> bash: ulimit: max locked memory: cannot modify limit: Operation not permitted
> $ echo $?
> 1
> 
> While that's the behaviour of Zsh:
> 
> % ulimit -l
> 64
> % ulimit -l unlimited
> % echo $?
> 0
> % ulimit -l
> 64
> 
> I find this quite irritating. Is that behaviour by intention? :)

I think it might be, but it's a little obscure and took some tracking
down.  It turns out if you set a soft limit to unlimited the shell is
smart / overdesigned enough to know that the maximum you can actually
set it to successfully is the value of the hard limit, so it silently
downgrades your "unlimited" request to the maximum you can actually
get.  (Line 670 of Src/Builtins/rlimits.c for those following along not
at home; line 652 does the same if the limit isn't known by
name/letter.  Whether setting the internal limits structure before a
system call that may fail is also problematic I don't know.)

Why I'm not sure it's intentional is the documentation says there's a
special value "hard" to set the limit to the value of the hard limit; it
says nothing about do this with the value "unlimited" that I can see.
This bypasses a lot of internal shell logic but ends up doing roughly
the same thing.

I suppose it could at least warn about this.

pws


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-10-06 13:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-06 12:30 ulimit behaviour of bash vs. zsh Michael Prokop
2014-10-06 13:23 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).