Lines Matching full:wo

1103 static int eligible_pid(struct wait_opts *wo, struct task_struct *p)  in eligible_pid()  argument
1105 return wo->wo_type == PIDTYPE_MAX || in eligible_pid()
1106 task_pid_type(p, wo->wo_type) == wo->wo_pid; in eligible_pid()
1110 eligible_child(struct wait_opts *wo, bool ptrace, struct task_struct *p) in eligible_child() argument
1112 if (!eligible_pid(wo, p)) in eligible_child()
1119 if (ptrace || (wo->wo_flags & __WALL)) in eligible_child()
1130 if ((p->exit_signal != SIGCHLD) ^ !!(wo->wo_flags & __WCLONE)) in eligible_child()
1142 static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p) in wait_task_zombie() argument
1149 if (!likely(wo->wo_flags & WEXITED)) in wait_task_zombie()
1152 if (unlikely(wo->wo_flags & WNOWAIT)) { in wait_task_zombie()
1158 if (wo->wo_rusage) in wait_task_zombie()
1159 getrusage(p, RUSAGE_BOTH, wo->wo_rusage); in wait_task_zombie()
1230 if (wo->wo_rusage) in wait_task_zombie()
1231 getrusage(p, RUSAGE_BOTH, wo->wo_rusage); in wait_task_zombie()
1234 wo->wo_stat = status; in wait_task_zombie()
1252 infop = wo->wo_info; in wait_task_zombie()
1282 * @wo: wait options
1298 static int wait_task_stopped(struct wait_opts *wo, in wait_task_stopped() argument
1309 if (!ptrace && !(wo->wo_flags & WUNTRACED)) in wait_task_stopped()
1326 if (!unlikely(wo->wo_flags & WNOWAIT)) in wait_task_stopped()
1347 if (wo->wo_rusage) in wait_task_stopped()
1348 getrusage(p, RUSAGE_BOTH, wo->wo_rusage); in wait_task_stopped()
1351 if (likely(!(wo->wo_flags & WNOWAIT))) in wait_task_stopped()
1352 wo->wo_stat = (exit_code << 8) | 0x7f; in wait_task_stopped()
1354 infop = wo->wo_info; in wait_task_stopped()
1370 static int wait_task_continued(struct wait_opts *wo, struct task_struct *p) in wait_task_continued() argument
1376 if (!unlikely(wo->wo_flags & WCONTINUED)) in wait_task_continued()
1388 if (!unlikely(wo->wo_flags & WNOWAIT)) in wait_task_continued()
1397 if (wo->wo_rusage) in wait_task_continued()
1398 getrusage(p, RUSAGE_BOTH, wo->wo_rusage); in wait_task_continued()
1401 infop = wo->wo_info; in wait_task_continued()
1403 wo->wo_stat = 0xffff; in wait_task_continued()
1422 static int wait_consider_task(struct wait_opts *wo, int ptrace, in wait_consider_task() argument
1436 ret = eligible_child(wo, ptrace, p); in wait_consider_task()
1446 wo->notask_error = 0; in wait_consider_task()
1476 return wait_task_zombie(wo, p); in wait_consider_task()
1499 if (likely(!ptrace) || (wo->wo_flags & (WCONTINUED | WEXITED))) in wait_consider_task()
1500 wo->notask_error = 0; in wait_consider_task()
1506 wo->notask_error = 0; in wait_consider_task()
1513 ret = wait_task_stopped(wo, ptrace, p); in wait_consider_task()
1522 return wait_task_continued(wo, p); in wait_consider_task()
1534 static int do_wait_thread(struct wait_opts *wo, struct task_struct *tsk) in do_wait_thread() argument
1539 int ret = wait_consider_task(wo, 0, p); in do_wait_thread()
1548 static int ptrace_do_wait(struct wait_opts *wo, struct task_struct *tsk) in ptrace_do_wait() argument
1553 int ret = wait_consider_task(wo, 1, p); in ptrace_do_wait()
1562 bool pid_child_should_wake(struct wait_opts *wo, struct task_struct *p) in pid_child_should_wake() argument
1564 if (!eligible_pid(wo, p)) in pid_child_should_wake()
1567 if ((wo->wo_flags & __WNOTHREAD) && wo->child_wait.private != p->parent) in pid_child_should_wake()
1576 struct wait_opts *wo = container_of(wait, struct wait_opts, in child_wait_callback() local
1580 if (pid_child_should_wake(wo, p)) in child_wait_callback()
1592 static bool is_effectively_child(struct wait_opts *wo, bool ptrace, in is_effectively_child() argument
1598 return current == parent || (!(wo->wo_flags & __WNOTHREAD) && in is_effectively_child()
1606 static int do_wait_pid(struct wait_opts *wo) in do_wait_pid() argument
1613 target = pid_task(wo->wo_pid, PIDTYPE_TGID); in do_wait_pid()
1614 if (target && is_effectively_child(wo, ptrace, target)) { in do_wait_pid()
1615 retval = wait_consider_task(wo, ptrace, target); in do_wait_pid()
1621 target = pid_task(wo->wo_pid, PIDTYPE_PID); in do_wait_pid()
1623 is_effectively_child(wo, ptrace, target)) { in do_wait_pid()
1624 retval = wait_consider_task(wo, ptrace, target); in do_wait_pid()
1632 long __do_wait(struct wait_opts *wo) in __do_wait() argument
1642 wo->notask_error = -ECHILD; in __do_wait()
1643 if ((wo->wo_type < PIDTYPE_MAX) && in __do_wait()
1644 (!wo->wo_pid || !pid_has_task(wo->wo_pid, wo->wo_type))) in __do_wait()
1649 if (wo->wo_type == PIDTYPE_PID) { in __do_wait()
1650 retval = do_wait_pid(wo); in __do_wait()
1657 retval = do_wait_thread(wo, tsk); in __do_wait()
1661 retval = ptrace_do_wait(wo, tsk); in __do_wait()
1665 if (wo->wo_flags & __WNOTHREAD) in __do_wait()
1672 retval = wo->notask_error; in __do_wait()
1673 if (!retval && !(wo->wo_flags & WNOHANG)) in __do_wait()
1679 static long do_wait(struct wait_opts *wo) in do_wait() argument
1683 trace_sched_process_wait(wo->wo_pid); in do_wait()
1685 init_waitqueue_func_entry(&wo->child_wait, child_wait_callback); in do_wait()
1686 wo->child_wait.private = current; in do_wait()
1687 add_wait_queue(&current->signal->wait_chldexit, &wo->child_wait); in do_wait()
1691 retval = __do_wait(wo); in do_wait()
1700 remove_wait_queue(&current->signal->wait_chldexit, &wo->child_wait); in do_wait()
1704 int kernel_waitid_prepare(struct wait_opts *wo, int which, pid_t upid, in kernel_waitid_prepare() argument
1753 wo->wo_type = type; in kernel_waitid_prepare()
1754 wo->wo_pid = pid; in kernel_waitid_prepare()
1755 wo->wo_flags = options; in kernel_waitid_prepare()
1756 wo->wo_info = infop; in kernel_waitid_prepare()
1757 wo->wo_rusage = ru; in kernel_waitid_prepare()
1759 wo->wo_flags |= WNOHANG; in kernel_waitid_prepare()
1767 struct wait_opts wo; in kernel_waitid() local
1770 ret = kernel_waitid_prepare(&wo, which, upid, infop, options, ru); in kernel_waitid()
1774 ret = do_wait(&wo); in kernel_waitid()
1775 if (!ret && !(options & WNOHANG) && (wo.wo_flags & WNOHANG)) in kernel_waitid()
1778 put_pid(wo.wo_pid); in kernel_waitid()
1818 struct wait_opts wo; in kernel_wait4() local
1844 wo.wo_type = type; in kernel_wait4()
1845 wo.wo_pid = pid; in kernel_wait4()
1846 wo.wo_flags = options | WEXITED; in kernel_wait4()
1847 wo.wo_info = NULL; in kernel_wait4()
1848 wo.wo_stat = 0; in kernel_wait4()
1849 wo.wo_rusage = ru; in kernel_wait4()
1850 ret = do_wait(&wo); in kernel_wait4()
1852 if (ret > 0 && stat_addr && put_user(wo.wo_stat, stat_addr)) in kernel_wait4()
1860 struct wait_opts wo = { in kernel_wait() local
1867 ret = do_wait(&wo); in kernel_wait()
1868 if (ret > 0 && wo.wo_stat) in kernel_wait()
1869 *stat = wo.wo_stat; in kernel_wait()
1870 put_pid(wo.wo_pid); in kernel_wait()