aboutsummaryrefslogtreecommitdiffstats
path: root/util-src/pposix.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-src/pposix.c')
-rw-r--r--util-src/pposix.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/util-src/pposix.c b/util-src/pposix.c
index 5e20def7..4ce55075 100644
--- a/util-src/pposix.c
+++ b/util-src/pposix.c
@@ -17,11 +17,17 @@
#if defined(__linux__)
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#else
+#ifndef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#endif
+#endif
+#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
+#endif
#include <stdlib.h>
#include <math.h>
@@ -52,7 +58,7 @@
#include <linux/falloc.h>
#endif
-#if !defined(WITHOUT_MALLINFO) && defined(__linux__)
+#if !defined(WITHOUT_MALLINFO) && defined(__linux__) && defined(__GLIBC__)
#include <malloc.h>
#define WITH_MALLINFO
#endif
@@ -104,14 +110,10 @@ static int lc_daemonize(lua_State *L) {
return 2;
}
- /* Close stdin, stdout, stderr */
- 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);
+ freopen("/dev/null", "r", stdin);
+ freopen("/dev/null", "w", stdout);
+ freopen("/dev/null", "w", stderr);
/* Final fork, use it wisely */
if(fork()) {
@@ -235,6 +237,7 @@ int lc_syslog_log(lua_State *L) {
}
int lc_syslog_close(lua_State *L) {
+ (void)L;
closelog();
if(syslog_ident) {
@@ -549,6 +552,7 @@ rlim_t arg_to_rlimit(lua_State *L, int idx, rlim_t current) {
if(strcmp(lua_tostring(L, idx), "unlimited") == 0) {
return RLIM_INFINITY;
}
+ return luaL_argerror(L, idx, "unexpected type");
case LUA_TNUMBER:
return lua_tointeger(L, idx);
@@ -647,6 +651,7 @@ int lc_getrlimit(lua_State *L) {
}
int lc_abort(lua_State *L) {
+ (void)L;
abort();
return 0;
}