summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2008-07-18 16:37:20 +1000
committerNeilBrown <neilb@suse.de>2008-07-18 16:37:20 +1000
commit9fe32043178f221526b6d59f3bbce58f777089da (patch)
tree6dc16f33e5fefbd801484f51ef0605af5d22eefb /util.c
parent8dfb8619f928d58ac7369c42e9f94dd0dabfed4b (diff)
mdmon: fork and run as a daemon.
start_mdmon now waits for mdmon to complete initialisation and, importantly, listen on the socket, before continuing. Signed-off-by: Neil Brown <neilb@suse.de>
Diffstat (limited to 'util.c')
-rw-r--r--util.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/util.c b/util.c
index fe46f3b0..3bf4cbe3 100644
--- a/util.c
+++ b/util.c
@@ -31,6 +31,7 @@
#include "md_p.h"
#include <sys/socket.h>
#include <sys/utsname.h>
+#include <sys/wait.h>
#include <sys/un.h>
#include <ctype.h>
#include <dirent.h>
@@ -1078,6 +1079,8 @@ int start_mdmon(int devnum)
{
int i;
int len;
+ pid_t pid;
+ int status;
char pathbuf[1024];
char *paths[4] = {
pathbuf,
@@ -1117,7 +1120,10 @@ int start_mdmon(int devnum)
case -1: fprintf(stderr, Name ": cannot run mdmon. "
"Array remains readonly\n");
return -1;
- default: ; /* parent - good */
+ default: /* parent - good */
+ pid = wait(&status);
+ if (pid < 0 || status != 0)
+ return -1;
}
return 0;
}