mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 13:28:27 +00:00
pid_ns: Extract functionality of exit of pid_ns helper in function
This functionality will be moved in criu task in next patches, the patch is a preparation. v2: Rename the function and move pr_err() to it. Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
67639620cb
commit
ec1de7aeb1
@ -283,6 +283,7 @@ static inline int pid_ns_root_off(void)
|
|||||||
extern int reserve_pid_ns_helpers(void);
|
extern int reserve_pid_ns_helpers(void);
|
||||||
extern int create_pid_ns_helper(struct ns_id *ns);
|
extern int create_pid_ns_helper(struct ns_id *ns);
|
||||||
extern int destroy_pid_ns_helpers(void);
|
extern int destroy_pid_ns_helpers(void);
|
||||||
|
extern void warn_if_pid_ns_helper_exited(pid_t real_pid);
|
||||||
extern int request_set_next_pid(int pid_ns_id, pid_t pid, int sk);
|
extern int request_set_next_pid(int pid_ns_id, pid_t pid, int sk);
|
||||||
|
|
||||||
#endif /* __CR_NS_H__ */
|
#endif /* __CR_NS_H__ */
|
||||||
|
@ -1585,29 +1585,36 @@ static void unsc_msg_pid_fd(struct unsc_msg *um, pid_t *pid, int *fd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void warn_if_pid_ns_helper_exited(pid_t real_pid)
|
||||||
|
{
|
||||||
|
struct ns_id *ns;
|
||||||
|
struct pid *pid;
|
||||||
|
|
||||||
|
for (ns = ns_ids; ns; ns = ns->next) {
|
||||||
|
if (ns->nd != &pid_ns_desc)
|
||||||
|
continue;
|
||||||
|
pid = __pstree_pid_by_virt(ns, ns->ns_pid);
|
||||||
|
if (pid->real == real_pid) {
|
||||||
|
pid->real = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ns)
|
||||||
|
pr_err("Spurious pid ns helper: pid=%d\n", real_pid);
|
||||||
|
}
|
||||||
|
|
||||||
static void usernsd_handler(int signal, siginfo_t *siginfo, void *data)
|
static void usernsd_handler(int signal, siginfo_t *siginfo, void *data)
|
||||||
{
|
{
|
||||||
pid_t pid = siginfo->si_pid;
|
pid_t pid = siginfo->si_pid;
|
||||||
struct ns_id *ns;
|
|
||||||
struct pid *tpid;
|
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
while (pid) {
|
while (pid) {
|
||||||
pid = waitpid(-1, &status, WNOHANG);
|
pid = waitpid(-1, &status, WNOHANG);
|
||||||
if (pid <= 0)
|
if (pid <= 0)
|
||||||
return;
|
return;
|
||||||
for (ns = ns_ids; ns; ns = ns->next) {
|
|
||||||
if (ns->nd != &pid_ns_desc)
|
|
||||||
continue;
|
|
||||||
tpid = __pstree_pid_by_virt(ns, ns->ns_pid);
|
|
||||||
if (tpid->real == pid) {
|
|
||||||
tpid->real = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ns)
|
warn_if_pid_ns_helper_exited(pid);
|
||||||
pr_err("Spurious pid ns helper: pid=%d\n", pid);
|
|
||||||
|
|
||||||
pr_err("%d finished unexpected: status=%d\n", pid, status);
|
pr_err("%d finished unexpected: status=%d\n", pid, status);
|
||||||
futex_abort_and_wake(&task_entries->nr_in_progress);
|
futex_abort_and_wake(&task_entries->nr_in_progress);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user