+/* Close stdin/stdout/stderr and replace with /dev/null */
+static int close_stdio(void) {
+ int fd;
+
+ if ((fd = open("/dev/null", O_RDWR)) == -1)
+ return -1;
+
+ if (dup2(fd, 0) == -1 || dup2(fd, 1) == -1 || dup2(fd, 2) == -1)
+ return -1;
+
+ close(fd);
+ return 0;
+}
+