[CRIU] [PATCH 03/14] util: clone service descriptors, if fd tables are shared for tasks (v3)
Andrew Vagin
avagin at parallels.com
Fri Jan 11 06:14:46 EST 2013
On Fri, Jan 11, 2013 at 02:34:01PM +0400, Pavel Emelyanov wrote:
>
> > +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?
The current process is already in a proper namespace.
If two process doesn't share fd tables, they will call
clone_service_fd(0).
>
> > +
> > + 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