projects
/
prosody.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util.pposix: Allow fetching RLIMIT_NICE when available
[prosody.git]
/
util-src
/
pposix.c
diff --git
a/util-src/pposix.c
b/util-src/pposix.c
index bda13ec020616dcb7b10231ab71d48fa6a9d3671..99a308cfea8f79ac8c626ad2392523cde2ed86d6 100644
(file)
--- a/
util-src/pposix.c
+++ b/
util-src/pposix.c
@@
-89,6
+89,10
@@
static int lc_daemonize(lua_State *L)
close(0);
close(1);
close(2);
close(0);
close(1);
close(2);
+ /* Make sure accidental use of FDs 0, 1, 2 don't cause weirdness */
+ open("/dev/null", O_RDONLY);
+ open("/dev/null", O_WRONLY);
+ open("/dev/null", O_WRONLY);
/* Final fork, use it wisely */
if(fork())
/* Final fork, use it wisely */
if(fork())
@@
-479,6
+483,9
@@
int string2resource(const char *s) {
if (!strcmp(s, "MEMLOCK")) return RLIMIT_MEMLOCK;
if (!strcmp(s, "NPROC")) return RLIMIT_NPROC;
if (!strcmp(s, "RSS")) return RLIMIT_RSS;
if (!strcmp(s, "MEMLOCK")) return RLIMIT_MEMLOCK;
if (!strcmp(s, "NPROC")) return RLIMIT_NPROC;
if (!strcmp(s, "RSS")) return RLIMIT_RSS;
+#endif
+#ifdef RLIMIT_NICE
+ if (!strcmp(s, "NICE")) return RLIMIT_NICE;
#endif
return -1;
}
#endif
return -1;
}
@@
-674,6
+681,10
@@
int lc_fallocate(lua_State* L)
lua_pushstring(L, strerror(errno));
return 2;
}
lua_pushstring(L, strerror(errno));
return 2;
}
+#else
+#warning Only using posix_fallocate() fallback.
+#warning Linux fallocate() is strongly recommended if available: recompile with -D_GNU_SOURCE
+#warning Note that posix_fallocate() will still be used on filesystems that dont support fallocate()
#endif
if(posix_fallocate(fileno(f), offset, len) == 0)
#endif
if(posix_fallocate(fileno(f), offset, len) == 0)