use pselect - from lars. testing now in a wider audience.

SVN revision: 33827
This commit is contained in:
Carsten Haitzler 2008-02-24 04:56:28 +00:00
parent a77a6eb18c
commit c31c2c50c3
2 changed files with 40 additions and 15 deletions

View File

@ -284,34 +284,35 @@ _ecore_main_shutdown(void)
static int
_ecore_main_select(double timeout)
{
struct timeval tv, *t;
fd_set rfds, wfds, exfds;
int max_fd;
int ret;
Ecore_List2 *l;
sigset_t emptyset;
struct timespec ts, *t;
fd_set rfds, wfds, exfds;
int max_fd;
int ret;
Ecore_List2 *l;
t = NULL;
if ((!finite(timeout)) || (timeout == 0.0)) /* finite() tests for NaN, too big, too small, and infinity. */
{
tv.tv_sec = 0;
tv.tv_usec = 0;
t = &tv;
ts.tv_sec = 0;
ts.tv_nsec = 0;
t = &ts;
}
else if (timeout > 0.0)
{
int sec, usec;
int sec, nsec;
#ifdef FIX_HZ
timeout += (0.5 / HZ);
sec = (int)timeout;
usec = (int)((timeout - (double)sec) * 1000000);
nsec = (int)((timeout - (double)sec) * 1000000000);
#else
sec = (int)timeout;
usec = (int)((timeout - (double)sec) * 1000000);
nsec = (int)((timeout - (double)sec) * 1000000000);
#endif
tv.tv_sec = sec;
tv.tv_usec = usec;
t = &tv;
ts.tv_sec = sec;
ts.tv_nsec = nsec;
t = &ts;
}
max_fd = 0;
FD_ZERO(&rfds);
@ -350,7 +351,9 @@ _ecore_main_select(double timeout)
}
}
if (_ecore_signal_count_get()) return -1;
ret = select(max_fd + 1, &rfds, &wfds, &exfds, t);
sigemptyset(&emptyset);
ret = pselect(max_fd + 1, &rfds, &wfds, &exfds, t, &emptyset);
if (ret < 0)
{
if (errno == EINTR) return -1;

View File

@ -113,10 +113,32 @@ _ecore_signal_shutdown(void)
void
_ecore_signal_init(void)
{
sigset_t blockset;
int ret;
#ifdef SIGRTMIN
int i, num = SIGRTMAX - SIGRTMIN;
#endif
sigemptyset(&blockset);
sigaddset(&blockset, SIGPIPE);
sigaddset(&blockset, SIGALRM);
sigaddset(&blockset, SIGCHLD);
sigaddset(&blockset, SIGUSR1);
sigaddset(&blockset, SIGUSR2);
sigaddset(&blockset, SIGHUP);
sigaddset(&blockset, SIGQUIT);
sigaddset(&blockset, SIGINT);
sigaddset(&blockset, SIGTERM);
#ifdef SIGPWR
sigaddset(&blockset, SIGPWR);
#endif
#ifdef SIGRTMIN
for (i = 0; i < num; i++)
sigaddset(&blockset, SIGRTMIN + i);
#endif
sigprocmask(SIG_BLOCK, &blockset, NULL);
_ecore_signal_callback_set(SIGPIPE, _ecore_signal_callback_ignore);
_ecore_signal_callback_set(SIGALRM, _ecore_signal_callback_ignore);
_ecore_signal_callback_set(SIGCHLD, _ecore_signal_callback_sigchld);