Re: [RESEND][RFC PATCH v2] waitfd

From: Oleg Nesterov
Date: Wed Jan 07 2009 - 12:21:44 EST


On 01/07, Ingo Molnar wrote:
>
> (Cc:-ed a few more folks who might be interested in this)
>
> * Casey Dahlin <cdahlin@xxxxxxxxxx> 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.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/