summaryrefslogtreecommitdiff
path: root/mdmon.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2013-02-05 15:57:09 +1100
committerNeilBrown <neilb@suse.de>2013-02-05 15:57:09 +1100
commit030419821fb77f9955f2017b4a6d3d8139d6db25 (patch)
tree4654d51c0449c1b83043faea24d7209a55df403e /mdmon.c
parent15c10423aa9435ed72bd292fecca69224a20fdc8 (diff)
mdmon: add --foreground option
While not strictly necessary for systemd, it is cleaner to avoid forking when running from a management daemon. So add a --foreground option to mdmon. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdmon.c')
-rw-r--r--mdmon.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/mdmon.c b/mdmon.c
index 8720aa53..007071be 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -288,11 +288,13 @@ int main(int argc, char *argv[])
int opt;
int all = 0;
int takeover = 0;
+ int dofork = 1;
static struct option options[] = {
{"all", 0, NULL, 'a'},
{"takeover", 0, NULL, 't'},
{"help", 0, NULL, 'h'},
{"offroot", 0, NULL, OffRootOpt},
+ {"foreground", 0, NULL, 'F'},
{NULL, 0, NULL, 0}
};
@@ -301,7 +303,7 @@ int main(int argc, char *argv[])
*/
argv[0][0] = '@';
- while ((opt = getopt_long(argc, argv, "tha", options, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "thaF", options, NULL)) != -1) {
switch (opt) {
case 'a':
container_name = argv[optind-1];
@@ -310,6 +312,9 @@ int main(int argc, char *argv[])
case 't':
takeover = 1;
break;
+ case 'F':
+ dofork = 0;
+ break;
case OffRootOpt:
/* silently ignore old option */
break;
@@ -381,7 +386,7 @@ int main(int argc, char *argv[])
container_name);
exit(1);
}
- return mdmon(devname, devnum, do_fork(), takeover);
+ return mdmon(devname, devnum, dofork && do_fork(), takeover);
}
static int mdmon(char *devname, int devnum, int must_fork, int takeover)