start_mdmon: provide more dynamic way to close-all-fds
When forking mdmon we need to close all other fds because we don't use O_CLOEXEC yet. Any approach will be fairly arbitrary, but as we can expect fds to be fairly dense, closing until we find a set number that don't need closing is possible safer than only closing the first 100. So keep closing until we find 20 that are already closed. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
75c2df6509
commit
1913c3256b
11
util.c
11
util.c
|
@ -1573,7 +1573,7 @@ int mdmon_running(int devnum)
|
|||
|
||||
int start_mdmon(int devnum)
|
||||
{
|
||||
int i;
|
||||
int i, skipped;
|
||||
int len;
|
||||
pid_t pid;
|
||||
int status;
|
||||
|
@ -1604,8 +1604,13 @@ int start_mdmon(int devnum)
|
|||
switch(fork()) {
|
||||
case 0:
|
||||
/* FIXME yuk. CLOSE_EXEC?? */
|
||||
for (i=3; i < 100; i++)
|
||||
close(i);
|
||||
skipped = 0;
|
||||
for (i=3; skipped < 20; i++)
|
||||
if (close(i) < 0)
|
||||
skipped++;
|
||||
else
|
||||
skipped = 0;
|
||||
|
||||
for (i=0; paths[i]; i++)
|
||||
if (paths[i][0])
|
||||
execl(paths[i], "mdmon",
|
||||
|
|
Loading…
Reference in New Issue