On Sat, Jan 26, 2008 at 01:16:24PM -0600, Nathan Ingersoll wrote:
> I checked the man page for Mac OS X as well. Looks like pselect()
> comes from FreeBSD in that case.
Ok, you got me convinced. Attached is a pselect version of the race fix.
Two questions remain:
1. Do we want to keep all signals blocked except in the pselect call or
do we want to unblock signals after the pselect call?
2. pselect breaks the win32 port. what is the best way to handle this?
implement our own pselect for win32 using select or use "#ifdef's" ?
Thanks
Lars Munch
Index: src/lib/ecore/ecore_main.c
===================================================================
RCS file: /var/cvs/e/e17/libs/ecore/src/lib/ecore/ecore_main.c,v
retrieving revision 1.33
diff -u -r1.33 ecore_main.c
--- src/lib/ecore/ecore_main.c 26 Jan 2008 10:11:48 -0000 1.33
+++ src/lib/ecore/ecore_main.c 29 Jan 2008 13:39:27 -0000
@@ -284,34 +284,35 @@
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 @@
}
}
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;
Index: src/lib/ecore/ecore_signal.c
===================================================================
RCS file: /var/cvs/e/e17/libs/ecore/src/lib/ecore/ecore_signal.c,v
retrieving revision 1.35
diff -u -r1.35 ecore_signal.c
--- src/lib/ecore/ecore_signal.c 26 Aug 2007 11:17:21 -0000 1.35
+++ src/lib/ecore/ecore_signal.c 29 Jan 2008 13:39:27 -0000
@@ -113,10 +113,37 @@
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);
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel