mdmon: don't fork if DEBUG
This commit is contained in:
parent
f54e6321a2
commit
16ddab0daf
48
mdmon.c
48
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 main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int mdfd;
|
int mdfd;
|
||||||
|
@ -196,23 +209,26 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fork, and have the child tell us when they are ready */
|
/* Fork, and have the child tell us when they are ready */
|
||||||
pipe(pfd);
|
if (do_fork()) {
|
||||||
switch(fork()){
|
pipe(pfd);
|
||||||
case -1:
|
switch(fork()) {
|
||||||
fprintf(stderr, "mdmon: failed to fork: %s\n",
|
case -1:
|
||||||
strerror(errno));
|
fprintf(stderr, "mdmon: failed to fork: %s\n",
|
||||||
exit(1);
|
strerror(errno));
|
||||||
case 0: /* child */
|
exit(1);
|
||||||
close(pfd[0]);
|
case 0: /* child */
|
||||||
break;
|
close(pfd[0]);
|
||||||
default: /* parent */
|
break;
|
||||||
close(pfd[1]);
|
default: /* parent */
|
||||||
if (read(pfd[0], &status, sizeof(status)) != sizeof(status)) {
|
close(pfd[1]);
|
||||||
wait(&status);
|
if (read(pfd[0], &status, sizeof(status)) != sizeof(status)) {
|
||||||
status = WEXITSTATUS(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 */
|
/* hopefully it is a container - we'll check later */
|
||||||
|
|
||||||
container = malloc(sizeof(*container));
|
container = malloc(sizeof(*container));
|
||||||
|
|
Loading…
Reference in New Issue