#ifndef HOST_WIN32
#include <sys/time.h>
#include <sys/types.h>
+#if defined(__APPLE__)
+#include "fakepoll.h"
+#else
#include <poll.h>
+#endif
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <mono/io-layer/atomic.h>
+#include <mono/metadata/appdomain.h>
#endif
G_BEGIN_DECLS
typedef void (*mph_sighandler_t)(int);
typedef struct Mono_Unix_UnixSignal_SignalInfo signal_info;
+#ifndef HOST_WIN32
static int count_handlers (int signum);
+#endif
void*
Mono_Posix_Stdlib_SIG_DFL (void)
#define mph_int_set(p,o,n) do { *(p) = n; } while (0)
#endif
+#if HAVE_PSIGNAL
int
Mono_Posix_Syscall_psignal (int sig, const char* s)
{
psignal (sig, s);
return errno == 0 ? 0 : -1;
}
+#endif /* def HAVE_PSIGNAL */
#define NUM_SIGNALS 64
static signal_info signals[NUM_SIGNALS];
}
}
+static inline int
+keep_trying (int r)
+{
+ return r == -1 && errno == EINTR;
+}
+
static void
default_handler (int signum)
{
pipecounter = mph_int_get (&h->pipecnt);
for (j = 0; j < pipecounter; ++j) {
int r;
- do { r = write (fd, &c, 1); } while (r == -1 && errno == EINTR);
+ do { r = write (fd, &c, 1); } while (keep_trying (r));
fsync (fd); /* force */
}
}
}
static int
-wait_for_any (signal_info** signals, int count, int *currfd, struct pollfd* fd_structs, int timeout)
+wait_for_any (signal_info** signals, int count, int *currfd, struct pollfd* fd_structs, int timeout, Mono_Posix_RuntimeIsShuttingDown shutting_down)
{
int r, idx;
do {
ptv = &tv;
}
r = poll (fd_structs, count, timeout);
- } while (r == -1 && errno == EINTR);
+ } while (keep_trying (r) && !shutting_down ());
idx = -1;
if (r == 0)
char c;
do {
r = read (h->read_fd, &c, 1);
- } while (r == -1 && errno == EINTR);
+ } while (keep_trying (r) && !shutting_down ());
if (idx == -1)
idx = i;
}
* index into _signals array of signal that was generated on success
*/
int
-Mono_Unix_UnixSignal_WaitAny (void** _signals, int count, int timeout /* milliseconds */)
+Mono_Unix_UnixSignal_WaitAny (void** _signals, int count, int timeout /* milliseconds */, Mono_Posix_RuntimeIsShuttingDown shutting_down)
{
int r;
int currfd = 0;
release_mutex (&signals_mutex);
if (r == 0) {
- r = wait_for_any (signals, count, &currfd, &fd_structs[0], timeout);
+ r = wait_for_any (signals, count, &currfd, &fd_structs[0], timeout, shutting_down);
}
if (acquire_mutex (&signals_mutex) == -1)