procd: get rid of putenv usage.
[project/procd.git] / initd / init.c
index 4d17563..0349e6e 100644 (file)
@@ -86,23 +86,15 @@ main(int argc, char **argv)
        if (!pid) {
                char *kmod[] = { "/sbin/kmodloader", "/etc/modules-boot.d/", NULL };
 
-               if (debug < 3) {
-                       int fd = open("/dev/null", O_RDWR);
-
-                       if (fd > -1) {
-                               dup2(fd, STDIN_FILENO);
-                               dup2(fd, STDOUT_FILENO);
-                               dup2(fd, STDERR_FILENO);
-                               if (fd > STDERR_FILENO)
-                                       close(fd);
-                       }
-               }
+               if (debug < 3)
+                       patch_stdio("/dev/null");
+
                execvp(kmod[0], kmod);
-               ERROR("Failed to start kmodloader\n");
+               ERROR("Failed to start kmodloader: %m\n");
                exit(-1);
        }
        if (pid <= 0) {
-               ERROR("Failed to start kmodloader instance\n");
+               ERROR("Failed to start kmodloader instance: %m\n");
        } else {
                int i;