util.pposix: Allow fetching RLIMIT_NICE when available
[prosody.git] / util-src / pposix.c
index 191e276ee1bc4576603feae2451924547bf5606d..99a308cfea8f79ac8c626ad2392523cde2ed86d6 100644 (file)
@@ -89,6 +89,10 @@ static int lc_daemonize(lua_State *L)
        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())
@@ -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;
+#endif
+#ifdef RLIMIT_NICE
+       if (!strcmp(s, "NICE")) return RLIMIT_NICE;
 #endif
        return -1;
 }