mirror of
https://github.com/labwc/labwc.git
synced 2026-04-07 08:21:20 -04:00
Replace _ with - in source file names
This commit is contained in:
parent
48742163fd
commit
23b96ad2a6
29 changed files with 28 additions and 28 deletions
42
src/common/fd-util.c
Normal file
42
src/common/fd-util.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
|
||||
#include <sys/resource.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
#include "common/fd-util.h"
|
||||
|
||||
static struct rlimit original_nofile_rlimit = {0};
|
||||
|
||||
void
|
||||
increase_nofile_limit(void)
|
||||
{
|
||||
if (getrlimit(RLIMIT_NOFILE, &original_nofile_rlimit) != 0) {
|
||||
wlr_log_errno(WLR_ERROR,
|
||||
"Failed to bump max open files limit: getrlimit(NOFILE) failed");
|
||||
return;
|
||||
}
|
||||
|
||||
struct rlimit new_rlimit = original_nofile_rlimit;
|
||||
new_rlimit.rlim_cur = new_rlimit.rlim_max;
|
||||
if (setrlimit(RLIMIT_NOFILE, &new_rlimit) != 0) {
|
||||
wlr_log_errno(WLR_ERROR,
|
||||
"Failed to bump max open files limit: setrlimit(NOFILE) failed");
|
||||
|
||||
wlr_log(WLR_INFO, "Running with %d max open files",
|
||||
(int)original_nofile_rlimit.rlim_cur);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
restore_nofile_limit(void)
|
||||
{
|
||||
if (original_nofile_rlimit.rlim_cur == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (setrlimit(RLIMIT_NOFILE, &original_nofile_rlimit) != 0) {
|
||||
wlr_log_errno(WLR_ERROR,
|
||||
"Failed to restore max open files limit: setrlimit(NOFILE) failed");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue