nspkg / tests / local_storage_probe.h
13 lines · 12 sloc · 479 bytes · c01b0795d1db56c7bce2539b2c46b110637fdc1a
Raw
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2#include <signal.h>
3#include <sys/resource.h>
4
5static int v_alpm_limit_database_write(void) {
6 struct rlimit limit;
7 struct sigaction action = {.sa_handler = SIG_IGN};
8 if(getrlimit(RLIMIT_FSIZE, &limit) != 0) { return -1; }
9 if(limit.rlim_cur > 128) { limit.rlim_cur = 128; }
10 sigemptyset(&action.sa_mask);
11 if(sigaction(SIGXFSZ, &action, NULL) != 0) { return -1; }
12 return setrlimit(RLIMIT_FSIZE, &limit);
13}
14