[CRIU] [PATCH 03/14] util: clone service descriptors, if fd tables are shared for tasks (v3)

Pavel Emelyanov xemul at parallels.com
Fri Jan 11 05:34:01 EST 2013


> +int clone_service_fd(int id)
> +{
> +	int ret = -1, i;
> +
> +	if (service_fd_id == id)
> +		return 0;

What does this check mean? Does it "shoot" ever? When?

> +
> +	for (i = SERVICE_FD_MIN + 1; i < SERVICE_FD_MAX; i++) {
> +		int old = __get_service_fd(i, service_fd_id);
> +		int new = __get_service_fd(i, id);
> +
> +		ret = dup2(old, new);
> +		if (ret == -1) {
> +			if (errno == EBADF)
> +				continue;
> +			pr_perror("Unalbe to clone %d->%d\n", old, new);
> +		}
> +	}
> +
> +	service_fd_id = id;
> +	ret = 0;
> +
> +	return ret;
>  }


More information about the CRIU mailing list