[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/3] getdtablesize: Extend RLIMIT_NOFILE fallback case to And

From: Kevin Cernekee
Subject: Re: [PATCH 2/3] getdtablesize: Extend RLIMIT_NOFILE fallback case to Android
Date: Mon, 23 Feb 2015 09:44:42 -0800

On Sun, Feb 22, 2015 at 7:11 PM, Paul Eggert <address@hidden> wrote:
> Kevin Cernekee wrote:
>> Based on comments in tests/test-sys_resource.c it looks like somebody
>> may have started a <sys/resource.h> replacement, but there is more
>> work to be done.
> Yes.  It's not clear how to implement all that stuff in the sys_resource
> module, so instead, how about the more-modest patch attached?  I've pushed
> it.

Now test-getdtablesize and test-fcntl pass.  But we have a new problem
with test-dup2, as this assertion is failing:

  /* Assigning to self must be a no-op.  */
  ASSERT (dup2 (fd, fd) == fd);

Under the hood, Bionic implements dup2() using dup3():

  int dup2(int old_fd, int new_fd) {
    return dup3(old_fd, new_fd, 0);

openat(AT_FDCWD, "test-dup2.tmp", O_RDWR|O_CREAT|O_TRUNC|O_LARGEFILE, 0600) = 3
fcntl64(3, F_GETFL)                     = 0x20002 (flags O_RDWR|O_LARGEFILE)
close(4)                                = -1 EBADF (Bad file descriptor)
close(5)                                = -1 EBADF (Bad file descriptor)
fcntl64(4, F_GETFL)                     = -1 EBADF (Bad file descriptor)
fcntl64(5, F_GETFL)                     = -1 EBADF (Bad file descriptor)
dup3(3, 3, 0)                           = -1 EINVAL (Invalid argument)
write(2, "test-dup2.c:123: assertion 'dup2"..., 56test-dup2.c:123:
assertion 'dup2 (fd, fd) == fd' failed
) = 56

and according to the man page, dup3() fails with EINVAL if oldfd ==
newfd.  Unlike dup2(), which should return newfd.

gnulib commit f9fa7159134175 ("dup2, fcntl: cross-compiler better for
Android") changed the logic to guess "yes" instead of "no" on the
question of whether dup2() is sane on Linux.  I suspect this was the
source of the regression?  Perhaps we need another a special case in
there for Android (attached).

Attachment: 0001-Replace-dup2-on-Android.patch
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]