]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb] Add gdb_select variant for looping
authorTom de Vries <tdevries@suse.de>
Fri, 22 Nov 2024 11:54:57 +0000 (12:54 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 22 Nov 2024 11:54:57 +0000 (12:54 +0100)
commitdcc4d678668bac6e3887ea04ff2337996629411e
treed03d49f200707d4955bf582f0ce8c9e755fde91a
parent3c557e1ae9c320efcfd4a7a91b752413a7bfd280
[gdb] Add gdb_select variant for looping

In interruptible_select we run gdb_select in a loop:
...
  do
    {
      res = gdb_select (n, readfds, writefds, exceptfds, timeout);
    }
  while (res == -1 && errno == EINTR);
...
but man select tells us that:
- if using select() within a loop, the sets (readfds, writefds and
  exceptfds) must be reinitialized before each call, and
- timeout should be considered to be undefined after select() returns.

Add a gdb_select variant:
...
static int
gdb_select (int n,
    const fd_set *req_readfds, fd_set *ret_readfds,
    const fd_set *req_writefds, fd_set *ret_writefds,
    const fd_set *req_exceptfds, fd_set *ret_exceptfds,
    const struct timeval *req_timeout, struct timeval *ret_timeout)
...
that keeps requested and returned values separate, ensuring that the requested
values stay constant.

Tested on x86_64-linux.

Reviewed-By: Alexandra Petlanova Hajkova <ahajkova@redhat.com>
gdb/event-top.c