]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdmon.c
tests: add test that DDF marks missing devices as failed on assembly.
[thirdparty/mdadm.git] / mdmon.c
diff --git a/mdmon.c b/mdmon.c
index 8cd53d8b24be4cf0936f90943e397cbe1d1ae97e..b84d4d9520485c04e55e7ebaccc844e0e81f2f67 100644 (file)
--- a/mdmon.c
+++ b/mdmon.c
@@ -429,6 +429,7 @@ static int mdmon(char *devnm, int must_fork, int takeover)
                                wait(&status);
                                status = WEXITSTATUS(status);
                        }
+                       close(pfd[0]);
                        return status;
                }
        } else
@@ -516,10 +517,12 @@ static int mdmon(char *devnm, int must_fork, int takeover)
        container->sock = make_control_sock(devnm);
 
        status = 0;
-       if (write(pfd[1], &status, sizeof(status)) < 0)
-               pr_err("failed to notify our parent: %d\n",
-                       getppid());
-       close(pfd[1]);
+       if (pfd[1] >= 0) {
+               if (write(pfd[1], &status, sizeof(status)) < 0)
+                       pr_err("failed to notify our parent: %d\n",
+                              getppid());
+               close(pfd[1]);
+       }
 
        mlockall(MCL_CURRENT | MCL_FUTURE);