Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

exit: add kernel_waitid_prepare() helper

Move the setup logic out of kernel_waitid(), and into a separate helper.

No functional changes intended in this patch.

Signed-off-by: Jens Axboe <axboe@kernel.dk>

+25 -13
+25 -13
kernel/exit.c
··· 1662 1662 return retval; 1663 1663 } 1664 1664 1665 - static long kernel_waitid(int which, pid_t upid, struct waitid_info *infop, 1666 - int options, struct rusage *ru) 1665 + static int kernel_waitid_prepare(struct wait_opts *wo, int which, pid_t upid, 1666 + struct waitid_info *infop, int options, 1667 + struct rusage *ru) 1667 1668 { 1668 - struct wait_opts wo; 1669 + unsigned int f_flags = 0; 1669 1670 struct pid *pid = NULL; 1670 1671 enum pid_type type; 1671 - long ret; 1672 - unsigned int f_flags = 0; 1673 1672 1674 1673 if (options & ~(WNOHANG|WNOWAIT|WEXITED|WSTOPPED|WCONTINUED| 1675 1674 __WNOTHREAD|__WCLONE|__WALL)) ··· 1711 1712 return -EINVAL; 1712 1713 } 1713 1714 1714 - wo.wo_type = type; 1715 - wo.wo_pid = pid; 1716 - wo.wo_flags = options; 1717 - wo.wo_info = infop; 1718 - wo.wo_rusage = ru; 1715 + wo->wo_type = type; 1716 + wo->wo_pid = pid; 1717 + wo->wo_flags = options; 1718 + wo->wo_info = infop; 1719 + wo->wo_rusage = ru; 1719 1720 if (f_flags & O_NONBLOCK) 1720 - wo.wo_flags |= WNOHANG; 1721 + wo->wo_flags |= WNOHANG; 1722 + 1723 + return 0; 1724 + } 1725 + 1726 + static long kernel_waitid(int which, pid_t upid, struct waitid_info *infop, 1727 + int options, struct rusage *ru) 1728 + { 1729 + struct wait_opts wo; 1730 + long ret; 1731 + 1732 + ret = kernel_waitid_prepare(&wo, which, upid, infop, options, ru); 1733 + if (ret) 1734 + return ret; 1721 1735 1722 1736 ret = do_wait(&wo); 1723 - if (!ret && !(options & WNOHANG) && (f_flags & O_NONBLOCK)) 1737 + if (!ret && !(options & WNOHANG) && (wo.wo_flags & WNOHANG)) 1724 1738 ret = -EAGAIN; 1725 1739 1726 - put_pid(pid); 1740 + put_pid(wo.wo_pid); 1727 1741 return ret; 1728 1742 } 1729 1743