ns: Use waitpid() in create_user_ns_hierarhy_fn()

Submitted by Kirill Tkhai on April 5, 2017, 9:43 a.m.

Details

Message ID 149138527115.6582.9918612800501102839.stgit@localhost.localdomain
State Accepted
Series "ns: Use waitpid() in create_user_ns_hierarhy_fn()"
Headers show

Commit Message

Kirill Tkhai April 5, 2017, 9:43 a.m.
We're interested in just created child only. Other possibly guys
will be handled in appropriate places later (criu task may have
helpers-children).

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/namespaces.c |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/namespaces.c b/criu/namespaces.c
index 031507d5a..3847bc40e 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -2354,16 +2354,15 @@  static int create_user_ns_hierarhy_fn(void *in_arg)
 			goto out;
 		}
 		futex_wait_while_lt(futex, NS__CREATED);
-		/* Get child real pid */
-		pid = arg->pid;
-		if (prepare_userns(pid, child->user.e) < 0) {
+		/* Use child real pid */
+		if (prepare_userns(arg->pid, child->user.e) < 0) {
 			pr_err("Can't prepare child user_ns\n");
 			goto out;
 		}
 		futex_set_and_wake(futex, NS__MAPS_POPULATED);
 
 		errno = 0;
-		if (wait(&status) < 0 || !WIFEXITED(status) || WEXITSTATUS(status)) {
+		if (waitpid(pid, &status, 0) < 0 || !WIFEXITED(status) || WEXITSTATUS(status)) {
 			pr_perror("Child process waiting: %d", status);
 			close_pid_proc();
 			goto out;

Comments

Andrey Vagin April 5, 2017, 6:12 p.m.
Applied

On Wed, Apr 05, 2017 at 12:43:34PM +0300, Kirill Tkhai wrote:
> We're interested in just created child only. Other possibly guys
> will be handled in appropriate places later (criu task may have
> helpers-children).
> 
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
> ---
>  criu/namespaces.c |    7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/criu/namespaces.c b/criu/namespaces.c
> index 031507d5a..3847bc40e 100644
> --- a/criu/namespaces.c
> +++ b/criu/namespaces.c
> @@ -2354,16 +2354,15 @@ static int create_user_ns_hierarhy_fn(void *in_arg)
>  			goto out;
>  		}
>  		futex_wait_while_lt(futex, NS__CREATED);
> -		/* Get child real pid */
> -		pid = arg->pid;
> -		if (prepare_userns(pid, child->user.e) < 0) {
> +		/* Use child real pid */
> +		if (prepare_userns(arg->pid, child->user.e) < 0) {
>  			pr_err("Can't prepare child user_ns\n");
>  			goto out;
>  		}
>  		futex_set_and_wake(futex, NS__MAPS_POPULATED);
>  
>  		errno = 0;
> -		if (wait(&status) < 0 || !WIFEXITED(status) || WEXITSTATUS(status)) {
> +		if (waitpid(pid, &status, 0) < 0 || !WIFEXITED(status) || WEXITSTATUS(status)) {
>  			pr_perror("Child process waiting: %d", status);
>  			close_pid_proc();
>  			goto out;
>