Commit a41a3b76 authored by Paolo \'Blaisorblade\' Giarrusso's avatar Paolo \'Blaisorblade\' Giarrusso Committed by Linus Torvalds

[PATCH] Uml: first part rework of run_helper() and users.

With Jeff Dike <jdike@addtoit.com>,

Fixed a file descriptor leak in the network driver when changing an IP
address.

Fixed the error handling in run_helper.

Paolo notes:

Actually, this is part one of the change, the exact one extracted from Jeff
Dike's incrementals tree before 2.6.9-rc big UML merge.

There is some changes must be done, so I'm also sending a second patch with
this one, too.  Separated for tracking purposes.
Signed-off-by: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 8723ef96
......@@ -173,8 +173,9 @@ static int change_tramp(char **argv, char *output, int output_len)
pe_data.stdout = fds[1];
pid = run_helper(change_pre_exec, &pe_data, argv, NULL);
os_close_file(fds[1]);
read_output(fds[0], output, output_len);
os_close_file(fds[0]);
os_close_file(fds[1]);
CATCH_EINTR(err = waitpid(pid, NULL, 0));
return(pid);
......
......@@ -94,24 +94,20 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv,
if(n < 0){
printk("run_helper : read on pipe failed, err = %d\n", -n);
err = n;
goto out_kill;
os_kill_process(pid, 1);
}
else if(n != 0){
CATCH_EINTR(n = waitpid(pid, NULL, 0));
pid = -errno;
}
err = pid;
if(stack_out == NULL) free_stack(stack, 0);
else *stack_out = stack;
return(pid);
out_kill:
os_kill_process(pid, 1);
out_close:
os_close_file(fds[0]);
os_close_file(fds[1]);
out_free:
free_stack(stack, 0);
if(stack_out == NULL)
free_stack(stack, 0);
else *stack_out = stack;
return(err);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment