PATCH: linux-generic dup2 behaviour
Linas Vepstas
linasvepstas@gmail.com
Wed Sep 14 16:07:00 GMT 2011
On 14 September 2011 07:55, Chris Metcalf <cmetcalf@tilera.com> wrote:
> On 9/13/2011 6:27 PM, Roland McGrath wrote:
>> The only option I see without a kernel change is to make libc's dup2 use a
>> special case for oldfd==newfd that just does a probe call like fcntl(oldfd,
>> F_GETFD, 0) for the sole purpose of detecting EBADF. I suspect kernel
>> folks will be likely to insist you to do that just so they don't have to
>> change the kernel.
>
> This certainly seems like the best way to me. That particular case is a
> pretty unuseful one anyway, so adding an extra syscall test is off the
> critical path, and won't take much code space either.
Yeah, I kind of figured that out shortly after hitting the "send" button.
I've got a mild cold, that's my excuse.
> Linas, if you're doing this work anyway and are running the m4 test, I'd be
> happy to incorporate the fix into the Tilera sources, which really, Any Day
> Now, I'll be submitting. :-)
I'll send a patch later this afternoon; I figure I should at least
test it first,
but that is easier said than done :-)
> In any case I'll add the m4 test suite to my
> list of things to confirm works properly.
The m4 test cases aren't all that stunning; for me, 3 of 108 failed,
and this patch should fix 2 of these. The third was test-readlink which
is expecting
readlink("", buf, sizeof buf);
to set ENOENT, and instead it sets EINVAL
I was willing to ascribe this to poor test case design, but now that
we're on topic... any suggestions?
--linas
More information about the Libc-ports
mailing list