zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <stephane@chazelas.org>
To: Daniel Shahaf <d.s@daniel.shahaf.name>,
	Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [PATCHv3 2/2] [long] improvements to limit/ulimit API and doc (the rest)
Date: Sat, 28 Nov 2020 08:16:32 +0000	[thread overview]
Message-ID: <20201128081632.7m4fd5bbxghyvzug@chazelas.org> (raw)
In-Reply-To: <20201127201342.t4uthqbfwuhzgevz@chazelas.org>

[sorry, should have been v3 in the subject of the email I'm
replying to by the way).

2020-11-27 20:13:42 +0000, Stephane Chazelas:
[...]
> I've tried to address that in this v3 patch. Specifying the type
> (as in char*, int...) seems redundant though and not generally
> done in other functions, so I've left it out for now.
[...]
> +	    if (shell) {
> +		/*
> +		 * FIXME: this is dead code as at the moment, there is no API
> +		 * for the user can request all limits *of the shell* be
> +		 * displayed.
> +		 *
> +		 * Should we add a "limit -s -a" or "limit -s all"?
> +		 */
[...]

And in my initial email:

> - I've made it so "limit -s filesize" reports the shell's own
>   limit (-s is for "set" initially, but it could also be "shell"
>   or "self"). But while "limit" outputs all children limits,
>   "limit -s" still copies those children limits to the shell's
>   and there's no way to print *all* self limits. That doesn't
>   make for a very intuitive API.

Maybe one approach could be to introduce some $shell_limits and
$children_limits special associative arrays indexed on limit
name (or number for those limits that don't have a name yet).

Which would allow things like:

(( shell_limits[filesize] >= min )) || die "can't do"

There's the problem of RLIM_INFINITY and the fact that rlim_t is
unsigned so if 64bit, allows values beyond the integer ones
supported by arithmetic evaluation.

Both could be addressed by making the value a floating point
number (append a . or e0 and use inf for RLIM_INFINITY), but
that sounds less than ideal as we're losing precision and limits
are really integers in the first place (and for consistency
limit/ulimit would need to be updated to accept floating point
on input).

There's also the problem that "limit" (contrary to ulimit) lets
you set more than one limit at a time, but not print more than
one limit at a time ("limit cputime" prints the value of
"cputime" but "limit cputime filesize" tries to set the cputime
limit to "filesize").

So, maybe a better approach is to add a "-p" for "print":

- limit or limit -p prints all the known limits for children
- limit -ps prints all the known limits for the shell
- limit -p filesize or limit filesize prints the filesize limit
- limit -p filesize cputime prints the filesize and cputime
  limits.

And maybe a "-r" for "raw" though there's always the problem of
RLIM_INFINITY and uint64.

And of course there's always the possibility of ignoring the
problem altogether as it's not as if anybody is going to miss
that feature very badly.

At the moment, one can always do:

(( ${$(ulimit -f)//unlimited/inf} >= ceil(min / 512.) )) ||
  die "can't do"

(though that's children_limits, and bearing in mind that ulimit
rounds down the number so we'll get false positives like when
min is 1 and the limit is 511B, rounded down to 0).

-- 
Stephane



  parent reply	other threads:[~2020-11-28  8:16 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23 21:49 [PATCHv1] [long] improvements to limit/ulimit API and doc Stephane Chazelas
2020-11-25  0:35 ` Daniel Shahaf
2020-11-25  6:44   ` Stephane Chazelas
2020-11-27 17:16     ` Daniel Shahaf
2020-11-26  6:57   ` [PATCHv2 1/2] [long] improvements to limit/ulimit API and doc ((un)limit in csh emulation) Stephane Chazelas
2020-11-25 23:43 ` [PATCHv1] [long] improvements to limit/ulimit API and doc Oliver Kiddle
2020-11-26 20:14   ` [PATCH] ulimit option completions using ulimit -a output Stephane Chazelas
2020-11-27  7:13     ` Stephane Chazelas
2020-11-27  8:15       ` Felipe Contreras
2020-11-27 12:19       ` Oliver Kiddle
2021-03-27 21:25         ` Lawrence Velázquez
2021-04-03 14:57           ` Lawrence Velázquez
2021-04-10 20:11             ` Lawrence Velázquez
2021-04-13 14:35     ` Daniel Shahaf
2021-05-09 20:37       ` Lawrence Velázquez
2021-05-11 19:05         ` Stephane Chazelas
2020-11-26 20:58   ` [PATCHv2 2/2] [long] improvements to limit/ulimit API and doc (the rest) Stephane Chazelas
2020-11-27 16:39     ` Daniel Shahaf
2020-11-27 20:13       ` Stephane Chazelas
2020-11-27 20:36         ` Daniel Shahaf
2020-11-28  6:52           ` zsh coding style (was about a limit patch review) Stephane Chazelas
2020-12-01 16:47             ` Daniel Shahaf
2020-11-28  8:16         ` Stephane Chazelas [this message]
2021-03-27 21:21           ` [PATCHv3 2/2] [long] improvements to limit/ulimit API and doc (the rest) Lawrence Velázquez
2021-03-31 18:06             ` Stephane Chazelas
2020-11-26 11:19 ` [PATCHv1] [long] improvements to limit/ulimit API and doc Jun T
2020-11-26 13:55   ` Stephane Chazelas
2020-11-26 15:22     ` Jun. T
2020-11-26 17:23       ` Stephane Chazelas
2020-11-27 18:24         ` Jun. T
2020-11-27 18:34           ` Daniel Shahaf
2020-11-27 20:46           ` Stephane Chazelas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201128081632.7m4fd5bbxghyvzug@chazelas.org \
    --to=stephane@chazelas.org \
    --cc=d.s@daniel.shahaf.name \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).