summaryrefslogtreecommitdiffstats
path: root/mdmon.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2008-07-24 17:26:24 -0700
committerDan Williams <dan.j.williams@intel.com>2008-07-24 17:26:24 -0700
commit16ddab0dafa2545aacf5361ce51cf10e150d2173 (patch)
tree36f6f017af6859663fdb703b2645cc860aac009c /mdmon.c
parentf54e6321a2efa01ea22cd6538c1e0e00b38c01fd (diff)
downloadmdadm-16ddab0dafa2545aacf5361ce51cf10e150d2173.tar.gz
mdadm-16ddab0dafa2545aacf5361ce51cf10e150d2173.tar.xz
mdadm-16ddab0dafa2545aacf5361ce51cf10e150d2173.zip
mdmon: don't fork if DEBUG
Diffstat (limited to 'mdmon.c')
-rw-r--r--mdmon.c48
1 files changed, 32 insertions, 16 deletions
diff --git a/mdmon.c b/mdmon.c
index d35c05b..85f44bc 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -169,6 +169,19 @@ static void wake_me(int sig)
}
+/* if we are debugging and starting mdmon by hand then don't fork */
+static int do_fork(void)
+{
+ #ifdef DEBUG
+ if (env_no_mdmon())
+ return 0;
+ #endif
+
+ return 1;
+}
+
+
+
int main(int argc, char *argv[])
{
int mdfd;
@@ -196,23 +209,26 @@ int main(int argc, char *argv[])
}
/* Fork, and have the child tell us when they are ready */
- pipe(pfd);
- switch(fork()){
- case -1:
- fprintf(stderr, "mdmon: failed to fork: %s\n",
- strerror(errno));
- exit(1);
- case 0: /* child */
- close(pfd[0]);
- break;
- default: /* parent */
- close(pfd[1]);
- if (read(pfd[0], &status, sizeof(status)) != sizeof(status)) {
- wait(&status);
- status = WEXITSTATUS(status);
+ if (do_fork()) {
+ pipe(pfd);
+ switch(fork()) {
+ case -1:
+ fprintf(stderr, "mdmon: failed to fork: %s\n",
+ strerror(errno));
+ exit(1);
+ case 0: /* child */
+ close(pfd[0]);
+ break;
+ default: /* parent */
+ close(pfd[1]);
+ if (read(pfd[0], &status, sizeof(status)) != sizeof(status)) {
+ wait(&status);
+ status = WEXITSTATUS(status);
+ }
+ exit(status);
}
- exit(status);
- }
+ } else
+ pfd[0] = pfd[1] = -1;
/* hopefully it is a container - we'll check later */
container = malloc(sizeof(*container));