]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - util.c
mdmon: fork and run as a daemon.
[thirdparty/mdadm.git] / util.c
diff --git a/util.c b/util.c
index fe46f3b02d9c20a58079e0f70f8b48d41308d1e5..3bf4cbe31d832eb124f5bf37315ec67f70ce912c 100644 (file)
--- a/util.c
+++ b/util.c
@@ -31,6 +31,7 @@
 #include       "md_p.h"
 #include       <sys/socket.h>
 #include       <sys/utsname.h>
+#include       <sys/wait.h>
 #include       <sys/un.h>
 #include       <ctype.h>
 #include       <dirent.h>
@@ -1078,6 +1079,8 @@ int start_mdmon(int devnum)
 {
        int i;
        int len;
+       pid_t pid;      
+       int status;
        char pathbuf[1024];
        char *paths[4] = {
                pathbuf,
@@ -1117,7 +1120,10 @@ int start_mdmon(int devnum)
        case -1: fprintf(stderr, Name ": cannot run mdmon. "
                         "Array remains readonly\n");
                return -1;
-       default: ; /* parent - good */
+       default: /* parent - good */
+               pid = wait(&status);
+               if (pid < 0 || status != 0)
+                       return -1;
        }
        return 0;
 }