libc: initialize tv struct in pselect

Fixes #3839
This commit is contained in:
Alexander Boettcher 2020-07-30 15:50:59 +02:00 committed by Norman Feske
parent 257b3b6775
commit bed531b604

View File

@ -374,18 +374,22 @@ extern "C" __attribute__((weak))
int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
const struct timespec *timeout, const sigset_t *sigmask)
{
struct timeval tv;
struct timeval tv { 0, 0 };
struct timeval *tv_ptr = nullptr;
sigset_t origmask;
int nready;
if (timeout) {
tv.tv_usec = timeout->tv_nsec / 1000;
tv.tv_sec = timeout->tv_sec;
tv_ptr = &tv;
}
if (sigmask)
sigprocmask(SIG_SETMASK, sigmask, &origmask);
nready = select(nfds, readfds, writefds, exceptfds, &tv);
nready = select(nfds, readfds, writefds, exceptfds, tv_ptr);
if (sigmask)
sigprocmask(SIG_SETMASK, &origmask, NULL);