| 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | #include <signal.h> |
| 3 | #include <sys/resource.h> |
| 4 | |
| 5 | static 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 |