Instead od adding it into __pidfd_prepare() place it where the actual file allocation happens and update the outdated comment.
Showing the changes to kernel/fork.c (1 of 2 files). Show all
Unified · Split
| @@ -2042,11 +2042,6 @@ static int __pidfd_prepare(struct pid *pid, unsigned int flags, struct file **re · 2041 unmodified lines | |||
| 2042 | if (IS_ERR(pidfd_file)) | 2042 | if (IS_ERR(pidfd_file)) |
| 2043 | return PTR_ERR(pidfd_file); | 2043 | return PTR_ERR(pidfd_file); |
| 2044 | 2044 | ||
| 2045 | /* | ||
| 2046 | * anon_inode_getfile() ignores everything outside of the | ||
| 2047 | * O_ACCMODE | O_NONBLOCK mask, set PIDFD_THREAD manually. | ||
| 2048 | */ | ||
| 2049 | pidfd_file->f_flags |= (flags & PIDFD_THREAD); | ||
| 2050 | *ret = pidfd_file; | 2045 | *ret = pidfd_file; |
| 2051 | return take_fd(pidfd); | 2046 | return take_fd(pidfd); |
| 2052 | } | 2047 | } |