# Re: \[PATCH 2/4\] exit: support non-blocking pidfds

- From: Oleg Nesterov \<oleg@redhat.com\>
- Date: 2020-09-01 16:12:19 
- List: linux-api
- Page: https://ratatoskr.run/linux-api/2020/09/6090156
- Thread: https://ratatoskr.run/linux-kselftest/2020/08/6088262/t.md

```text
On 08/31, Christian Brauner wrote:
>
> --- 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().

> @@ -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;

?

Oleg.

```
