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

Bug#51877: poll() rejects the rlimit.rlim_cur fds



Package: libc6
Version: 2.1.2-1

The attached C++ program produces the output:
rlim_cur = 1024
error: Invalid argument

But I think it should output:
rlim_cur = 1024

then block forever on the poll().

poll() is incorrectly returning an "Invalid argument" for a number of
fds that is reported by getrlimit to be valid.  Changing the second
parameter of poll() to 32 causes it to work, but 33 does not work.

This is using the 2.2.12 kernel from the debian install (not
recompiled):
	uname -a
	Linux cristy 2.2.12 #1 Thu Oct 14 09:29:24 EST 1999 i586 unknown
	gcc -v
	Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.2/specs
	gcc version 2.95.2 19991109 (Debian GNU/Linux)


The program behaves correctly on my 2.0.34 kernel that has been
modified and recompiled to allow 1024 fds.

David Marwood

----------------------------------------------------------------

#include <sys/resource.h>
#include <errno.h>
#include <stdio.h>
#include <sys/poll.h>


void main(void)
{
  rlimit limit;
  getrlimit(RLIMIT_NOFILE, &limit);

  pollfd pollFds[50000];
  for (int i = 0; i < 50000; i++) pollFds[i].fd = -1;

  printf("rlim_cur = %d\n", limit.rlim_cur);

  int err = poll(pollFds, limit.rlim_cur, -1);

  perror("error");
}


Reply to: