On Tue, Sep 01, 2020 at 06:11:54PM +0200, Oleg Nesterov wrote:
On 08/31, Christian Brauner wrote:
quoted
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -934,6 +934,7 @@ struct wait_opts {
wait_queue_entry_t child_wait;
int notask_error;
+ int eagain_error;
};
static int eligible_pid(struct wait_opts *wo, struct task_struct *p)@@ -1461,6 +1462,8 @@ static long do_wait(struct wait_opts *wo)
notask:
retval = wo->notask_error;
+ if (!retval)
+ retval = wo->eagain_error;
if (!retval && !(wo->wo_flags & WNOHANG)) {
retval = -ERESTARTSYS;
I must have missed something but I don't understand why do we need
the new ->eagain_error and the change in do_wait().
quoted
@@ -1544,6 +1551,11 @@ static long kernel_waitid(int which, pid_t upid, struct waitid_info *infop,
wo.wo_flags = options;
wo.wo_info = infop;
wo.wo_rusage = ru;
+ wo.eagain_error = 0;
+ if (f_flags & O_NONBLOCK) {
+ wo.wo_flags |= WNOHANG;
+ wo.eagain_error = -EAGAIN;
+ }
ret = do_wait(&wo);
Can't kernel_waitid() simply do
if (f_flags & O_NONBLOCK)
wo.wo_flags |= WNOHANG;
ret = do_wait();
if (!ret & (f_flags & O_NONBLOCK))
ret = -EAGAIN;
?
Heh, indeed, that's even a smaller patch. Will change to that!
Thanks for the review, Oleg!
Christia