Re: [RESEND][RFC PATCH v2] waitfd

Oleg Nesterov
2009-01-07T17:21:43Z

On 01/07, Ingo Molnar wrote:
>
> (Cc:-ed a few more folks who might be interested in this)
>
> * Casey Dahlin <cdahlin@redhat.com> wrote:
>
> > +asmlinkage long sys_waitfd(int which, pid_t upid, int options, int unused)
> > +{
> > + int ufd;
> > + struct waitfd_ctx *ctx;
> > +
> > + /* Just to make sure we don't end up with a sys_waitfd4 */
> > + (void)unused;
>
> looks a bit silly ...
>
> > +
> > + if (options & ~(WNOHANG|WEXITED|WSTOPPED|WCONTINUED))
> > + return -EINVAL;
> > + if (!(options & (WEXITED|WSTOPPED|WCONTINUED)))
> > + return -EINVAL;
> > +
> > + ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
> > + if (!ctx)
> > + return -ENOMEM;
> > +
> > + ctx->ops = options;
> > + ctx->upid = upid;
> > + ctx->which = which;
> > +
> > + ufd = anon_inode_getfd("[waitfd]", &waitfd_fops, ctx,
> > + (options & WNOHANG) ? O_NONBLOCK : 0);

minor nit...

Please note that unlike other sys_...fd() syscalls, sys_waitfd()
doesn't allow to pass O_CLOEXEC. Looks like we need a separate
"flags" argument...

Also, ioctl(FIONBIO) or fcntl(O_NONBLOCK) have no effect on
waitfd, not very good.

I'd suggest to remove WNOHANG from waitfd_ctx->ops and treat
(->f_flags & O_NONBLOCK) as WNOHANG.

(can't resist, ->ops is not the best name ;)

Oleg.