criu/include/servicefd.h
Pavel Emelyanov e8ac085af8 Revert "crtools: close all desriptors only for the root task"
We have a race. Consider we have 3 tasks, A, B and C. A and B
share fdtable, C -- does not. Then we might be in a situation
when A is restoring memory reading mem images, and B -- forking
the C child. In that case descriptors held by A (for mem restore)
will be inherited by C and will not get closed.

This reverts commit d36e07aabe.
2014-04-21 14:48:05 +04:00

32 lines
828 B
C

#ifndef __CR_SERVICE_FD_H__
#define __CR_SERVICE_FD_H__
#include <stdbool.h>
enum sfd_type {
SERVICE_FD_MIN,
LOG_FD_OFF,
IMG_FD_OFF,
PROC_FD_OFF, /* fd with /proc for all proc_ calls */
CTL_TTY_OFF,
SELF_STDIN_OFF,
CR_PROC_FD_OFF, /* some other's proc fd.
* For dump -- target ns' proc
* For restore -- CRIU ns' proc
*/
ROOT_FD_OFF, /* Root of the namespace we dump/restore */
SERVICE_FD_MAX
};
extern int clone_service_fd(int id);
extern int init_service_fd(void);
extern int get_service_fd(enum sfd_type type);
extern int reserve_service_fd(enum sfd_type type);
extern int install_service_fd(enum sfd_type type, int fd);
extern int close_service_fd(enum sfd_type type);
extern bool is_service_fd(int fd, enum sfd_type type);
extern bool is_any_service_fd(int fd);
#endif /* __CR_SERVICE_FD_H__ */