Web lists-archives.com

Re: Stretch - bash crash when reach ulimit file size




On Fri, Jan 26, 2018 at 03:45:22PM +0000, Peter Hillier-Brook wrote:
> On 26/01/18 10:47, Felipe Salvador wrote:
> >     $ while true; do echo a>>a; done
> > 
> > makes bash crash when file size is reached

> A crash is always a bug. I suggest that you report it as such - if not
> already reported.

Yes, it's a bug in his script.  Not in bash.

Resource limits are quite low-level; they are implemented as kernel
system calls (see setrlimit(2)).  Processes which violate a resource
limit are signalled by the kernel.

In the case of RLIMIT_FSIZE:

              This is the maximum size of files that the process  may  create.
              Attempts  to  extend a file beyond this limit result in delivery
              of a SIGXFSZ signal.   By  default,  this  signal  terminates  a
              process,  but  a process can catch this signal instead, in which
              case the relevant  system  call  (e.g.,  write(2),  truncate(2))
              fails with the error EFBIG.

If the OP wants the script to exit gracefully, then a signal trap
must be set up.  Otherwise, the shell is simply terminated.