Factor common code into new "start_mdmon".
[thirdparty/mdadm.git] / Incremental.c
index e9a5457..9b22220 100644 (file)
@@ -836,28 +836,9 @@ int Incremental_container(struct supertype *st, char *devname, int verbose,
                                sysfs_set_str(sra, NULL, "array_state",
                                              "readonly");
                                /* start mdmon if needed. */
-                               if (mdmon_running(st->container_dev))
-                                       signal_mdmon(st->container_dev);
-                               else if (!env_no_mdmon()) {
-                                       int dn = st->container_dev;
-                                       int i;
-                                       switch(fork()) {
-                                       case 0:
-                                               /* FIXME yuk. CLOSE_EXEC?? */
-                                               for (i=3; i < 100; i++)
-                                                       close(i);
-                                               execl("./mdmon", "mdmon",
-                                                     map_dev(dev2major(dn),
-                                                             dev2minor(dn),
-                                                             1), NULL);
-                                               exit(1);
-                                       case -1: fprintf(stderr, Name
-                                                        ": cannot fork. "
-                                                 "Array remains readonly\n");
-                                               return 1;
-                                       default: ; /* parent - good */
-                                       }
-                               }
+                               if (!mdmon_running(st->container_dev))
+                                       start_mdmon(st->container_dev);
+                               ping_monitor(devnum2devname(st->container_dev));
                                break;
                        }
                        if (verbose >= 0)