Commit 20d697a1 authored by dons's avatar dons

[project @ 2004-10-02 07:32:25 by dons]

When linking against libpthreads, raise(3) can behave strangely on
some platforms (OpenBSD at least, maybe other BSDs, not Linux). So use
pthread_kill() to generate signals when running the threaded rts,
instead of raise(), when System.Posix.Signals.raiseSignal is called.

raiseSignal will call genericRaise, in the rts, which knows which
function to use.
parent 1749c262
......@@ -414,6 +414,7 @@ typedef struct _RtsSymbolVal {
SymX(gcdIntegerIntzh_fast) \
SymX(gcdIntzh_fast) \
SymX(genSymZh) \
SymX(genericRaise) \
SymX(getProgArgv) \
SymX(getStablePtr) \
SymX(initLinker) \
......
......@@ -32,6 +32,15 @@
#include <stdarg.h>
#include <stdio.h>
#if defined(openbsd_TARGET_OS)
# ifdef HAVE_SIGNAL_H
# include <signal.h>
# endif
# ifdef HAVE_PTHREAD_H
# include <pthread.h>
# endif
#endif
/* -----------------------------------------------------------------------------
Result-checking malloc wrappers.
-------------------------------------------------------------------------- */
......@@ -288,3 +297,19 @@ heapCheckFail( void )
}
#endif
/*
* It seems that pthreads and signals interact oddly in OpenBSD
* pthreads (and possibly FreeBSD). When linking with -lpthreads, we
* have to use pthread_kill to send blockable signals. So use that
* when we have a threaded rts. So System.Posix.Signals will call
* genericRaise(), rather than raise(3).
*/
#if defined(openbsd_TARGET_OS)
int genericRaise(int sig) {
# if defined(THREADED_RTS)
return pthread_kill(pthread_self(), sig);
# else
return raise(sig);
# endif
}
#endif
......@@ -50,4 +50,8 @@ extern void heapCheckFail( void );
extern void* __hscore_get_saved_termios(int fd);
extern void __hscore_set_saved_termios(int fd, void* ts);
#if defined(openbsd_TARGET_OS)
extern int genericRaise(int sig);
#endif
#endif // RTSUTILS_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment