Re: ulimit -c unlimited

2017-07-26 Thread Reuti

> Am 26.07.2017 um 03:43 schrieb 積丹尼 Dan Jacobson :
> 
> $ ulimit -c 99
> $ ulimit -c 99
> $ ulimit -c unlimited
> bash: ulimit: core file size: cannot modify limit: Operation not permitted
> 
> Maybe say: try again with numbers, not letters.

Do you get this as root too?

If the hard limit is unlimited, then you can raise the soft limit again also as 
normal user to be unlimited. So the statement "Operation not permitted" is 
correct, although it means: "can't raise hard limit again" as without -S or -H 
it sets both limits. The soft limit OTOH can be changed between a value and 
unlimited as often as you like, as the long as the hard limit stays to be set 
to unlimited.

-- Reuti




Re: ulimit -c unlimited

2017-07-26 Thread Chet Ramey
On 7/25/17 9:43 PM, 積丹尼 Dan Jacobson wrote:
> $ ulimit -c 99
> $ ulimit -c 99
> $ ulimit -c unlimited
> bash: ulimit: core file size: cannot modify limit: Operation not permitted

The limits are not quite what you think they are.  Here's what happens on
my system.

The core file size limit starts at 0 (the soft limit).  The hard limit is
9223372036854775807.

The first command sets the hard and the soft limits to 99,
scaled by the block factor, since ulimit sets both the hard and soft limits
unless otherwise directed.

The second command lowers the hard and soft limits to 99, again
scaled by the block factor. This is permitted.

The third command attempts to increase the limit beyond the current hard
limit. If you're not root, this is not permitted.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Re: ulimit -c unlimited

2017-07-26 Thread 積丹尼 Dan Jacobson
$  ulimit -c
0
$  ulimit -c 99
$  ulimit -c
99
$  ulimit -c 99
bash: ulimit: 99: limit out of range
$  ulimit -c 999
bash: ulimit: 999: limit out of range
$  ulimit -c 999
bash: ulimit: 999: limit out of range

Hmmm, maybe make the above error message say what the range is, so the
user doesn't have to probe it. Or say "do ... to see the valid range".


$  ulimit -c 9
bash: ulimit: core file size: cannot modify limit: Operation not permitted
$  ulimit -c 99
bash: ulimit: core file size: cannot modify limit: Operation not permitted
$  ulimit -c 99
bash: ulimit: core file size: cannot modify limit: Operation not permitted

By this time the user has probably given up... thinking that it isn't
the value that is the problem, but the basic Operation. (But if he
probes further, indeed some values work.)

$  ulimit -c 99
$  ulimit -c 999
bash: ulimit: core file size: cannot modify limit: Operation not permitted

Odd, a little later I try
$ ulimit -c 99
bash: ulimit: core file size: cannot modify limit: Operation not permitted

> "R" == Reuti   writes:

R> Do you get this as root too?

I'm just trying to say the messages are confusing for the normal user.
I don't want make my report too big, so am not trying it for root.

R> If the hard limit is unlimited, then you can raise the soft limit
R> again also as normal user to be unlimited. So the statement "Operation
R> not permitted" is correct, although it means: "can't raise hard limit
R> again" as without -S or -H it sets both limits. The soft limit OTOH
R> can be changed between a value and unlimited as often as you like, as
R> the long as the hard limit stays to be set to unlimited.

Hmmm...Wait... I was using "help ulimit",
now I see on the bash man page

  The -H and -S options specify that the hard or soft limit is set
  for the given resource.  A hard limit cannot be increased  by  a
  non-root  user  once it is set; a soft limit may be increased up
  to the value of the hard limit.

So maybe that explains why the user can only set it once (99 above) then
cannot change it...

OK I recommend the "help ulimit" now say

  [-S|-H] -aall current limits are reported
  [-S|-H] -bthe socket buffer size
  [-S|-H] -cthe maximum size of core files created
  [-S|-H] -dthe maximum size of a process's data segment
  [-S|-H] -ethe maximum scheduling priority (`nice')
  [-S|-H] -fthe maximum size of files written by the shell and its 
children

and perhaps the same on the bash man page.



Re: ulimit -c unlimited

2017-07-26 Thread 積丹尼 Dan Jacobson
CR> The third command attempts to increase the limit beyond the current hard
CR> limit. If you're not root, this is not permitted.

I find it odd that a normal user can raise it only once...



Re: ulimit -c unlimited

2017-07-26 Thread Greg Wooledge
On Wed, Jul 26, 2017 at 10:22:49PM +0800, 積丹尼 Dan Jacobson wrote:
> $  ulimit -c 99
> bash: ulimit: 99: limit out of 
> range
> $  ulimit -c 999
> bash: ulimit: 999: limit out of range
> $  ulimit -c 999
> bash: ulimit: 999: limit out of range
> 
> Hmmm, maybe make the above error message say what the range is, so the
> user doesn't have to probe it. Or say "do ... to see the valid range".

It's not really a bash thing.  It's an underlying operating system
(kernel) thing.  See "man setrlimit" for the libc interface.

Bash doesn't really have any way of knowing what the valid ranges are.
That isn't part of the getrlimit/setrlimit interface.  The only things
you can ask for are the current hard and soft limits.