mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 18:25:14 +00:00
criu/files: Add function to return unused FD by pid
Add a new global function to return unused FD based on the pid. This function can be used in situations where we need a FD that will not conflict with FDs used by target restore process, but struct pstree_item is not available (e.g plugins) Signed-off-by: David Yat Sin <david.yatsin@amd.com>
This commit is contained in:
parent
653eefea0c
commit
e04db02411
2 changed files with 13 additions and 0 deletions
12
criu/files.c
12
criu/files.c
|
|
@ -183,6 +183,18 @@ out:
|
|||
return fd;
|
||||
}
|
||||
|
||||
int find_unused_fd_pid(pid_t pid)
|
||||
{
|
||||
struct pstree_item *task;
|
||||
|
||||
task = pstree_item_by_virt(pid);
|
||||
if (!task) {
|
||||
pr_err("Invalid pid:%d\n", pid);
|
||||
return -1;
|
||||
}
|
||||
return find_unused_fd(task, -1);
|
||||
}
|
||||
|
||||
int set_fds_event(pid_t virt)
|
||||
{
|
||||
struct pstree_item *item;
|
||||
|
|
|
|||
|
|
@ -195,4 +195,5 @@ extern int open_transport_socket(void);
|
|||
extern int set_fds_event(pid_t virt);
|
||||
extern void wait_fds_event(void);
|
||||
|
||||
int find_unused_fd_pid(pid_t pid);
|
||||
#endif /* __CR_FILES_H__ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue