shlib.sh: provide git_ulimit function and var_xfsz_err
commitfeed52d242f5f4fb2c7beacbbd27aac32bf6dd39
authorKyle J. McKay <mackyle@gmail.com>
Sat, 15 Aug 2020 20:00:06 +0000 (15 13:00 -0700)
committerKyle J. McKay <mackyle@gmail.com>
Sat, 15 Aug 2020 20:00:06 +0000 (15 13:00 -0700)
tree233c727b8faecf247f9c423e6acc8113c09d13ac
parentfa7b6a73997a495c71c11c92b9240198663bf944
shlib.sh: provide git_ulimit function and var_xfsz_err

In order to implement the new $Girocco::Config::max_file_size512
setting, it's necessary to run git using the ulimit512 utility.

Provide a new git_ulimit function that does so if the max_file_size512
variable has been set to a non-zero value (otherwise just run git
normally).

While it would certainly be possible to always run git with the
limit in place, it's only needed during fetching/receiving of new
objects and it's better to avoid setting it during other operations
(especially gc) that could, perhaps, be adversely affected by such
a limit.

When a command fails because it receives SIGXFSZ (and it does not
have a signal handler for it installed), the shell will report that
as an exit status of 128+<signal number>.

Unfortunately, the actual signal number assigned to SIGXFSZ is not
standardized by POSIX (although it's likely 25 on many systems).

Therefore, test the actual failure at install time and set a new
"var_xfsz_err" variable to the exit code the shell will report for
a SIGXFSZ termination on the current system.  This makes it possible
to reliably test for such a failure later.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
shlib.sh