Merge f78e9de80f ("Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input") into android-mainline
Steps on the way to 5.16-rc1 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I78a89c32422b0b415dff9682ec10f464846c2c66
This commit is contained in:
@@ -540,6 +540,42 @@ struct pid *pidfd_get_pid(unsigned int fd, unsigned int *flags)
|
||||
return pid;
|
||||
}
|
||||
|
||||
/**
|
||||
* pidfd_get_task() - Get the task associated with a pidfd
|
||||
*
|
||||
* @pidfd: pidfd for which to get the task
|
||||
* @flags: flags associated with this pidfd
|
||||
*
|
||||
* Return the task associated with @pidfd. The function takes a reference on
|
||||
* the returned task. The caller is responsible for releasing that reference.
|
||||
*
|
||||
* Currently, the process identified by @pidfd is always a thread-group leader.
|
||||
* This restriction currently exists for all aspects of pidfds including pidfd
|
||||
* creation (CLONE_PIDFD cannot be used with CLONE_THREAD) and pidfd polling
|
||||
* (only supports thread group leaders).
|
||||
*
|
||||
* Return: On success, the task_struct associated with the pidfd.
|
||||
* On error, a negative errno number will be returned.
|
||||
*/
|
||||
struct task_struct *pidfd_get_task(int pidfd, unsigned int *flags)
|
||||
{
|
||||
unsigned int f_flags;
|
||||
struct pid *pid;
|
||||
struct task_struct *task;
|
||||
|
||||
pid = pidfd_get_pid(pidfd, &f_flags);
|
||||
if (IS_ERR(pid))
|
||||
return ERR_CAST(pid);
|
||||
|
||||
task = get_pid_task(pid, PIDTYPE_TGID);
|
||||
put_pid(pid);
|
||||
if (!task)
|
||||
return ERR_PTR(-ESRCH);
|
||||
|
||||
*flags = f_flags;
|
||||
return task;
|
||||
}
|
||||
|
||||
/**
|
||||
* pidfd_create() - Create a new pid file descriptor.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user