app: Introduce some routines to help with application startup
[osmocom-bb.git] / src / process.c
index ab4b37e..7f4f12c 100644 (file)
@@ -23,7 +23,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
-#include <sys/types.h>
 #include <sys/stat.h>
 
 int osmo_daemonize(void)
@@ -63,9 +62,12 @@ int osmo_daemonize(void)
                return rc;
 
        /* Redirect stdio to /dev/null */
+/* since C89/C99 says stderr is a macro, we can safely do this! */
+#ifdef stderr
        freopen("/dev/null", "r", stdin);
        freopen("/dev/null", "w", stdout);
        freopen("/dev/null", "w", stderr);
+#endif
 
        return 0;
 }