Skip to content

Commit 41221b3

Browse files
committed
2009-01-08 Rodrigo Kumpera <[email protected]>
* signal.c: Don't allow registration of a realtime signal to happen if it was already registered outside of Mono.Posix. svn path=/trunk/mono/; revision=122755
1 parent 9a07c29 commit 41221b3

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

support/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2009-01-08 Rodrigo Kumpera <[email protected]>
2+
3+
* signal.c: Don't allow registration of a realtime signal to happen
4+
if it was already registered outside of Mono.Posix.
5+
16
2008-12-19 Jonathan Pryor <[email protected]>
27

38
* signal.c: Improve error checking within Mono_Posix_FromRealTimeSignum.

support/signal.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ G_BEGIN_DECLS
2929
typedef void (*mph_sighandler_t)(int);
3030
typedef struct Mono_Unix_UnixSignal_SignalInfo signal_info;
3131

32+
static int count_handlers (int signum);
33+
3234
void*
3335
Mono_Posix_Stdlib_SIG_DFL (void)
3436
{
@@ -157,6 +159,19 @@ Mono_Unix_UnixSignal_install (int sig)
157159
return NULL;
158160
}
159161

162+
#if defined (SIGRTMIN) && defined (SIGRTMAX)
163+
/*The runtime uses some rt signals for itself so it's important to not override them.*/
164+
if (sig >= SIGRTMIN && sig <= SIGRTMAX && count_handlers (sig) == 0) {
165+
struct sigaction sinfo;
166+
sigaction (sig, NULL, &sinfo);
167+
if (sinfo.sa_handler != SIG_DFL || (void*)sinfo.sa_sigaction != (void*)SIG_DFL) {
168+
pthread_mutex_unlock (&signals_mutex);
169+
errno = EADDRINUSE;
170+
return NULL;
171+
}
172+
}
173+
#endif /*defined (SIGRTMIN) && defined (SIGRTMAX)*/
174+
160175
for (i = 0; i < NUM_SIGNALS; ++i) {
161176
if (h == NULL && signals [i].signum == 0) {
162177
h = &signals [i];

0 commit comments

Comments
 (0)