wolfgang.thaller:
> >  When linking against libpthreads, raise(3) can behave strangely on
> >  some platforms (OpenBSD at least, maybe other BSDs, not Linux).
> 
> In what way does it behave strangely? Can you give me a hint on how to 
> check for the same problem on Mac OS X?

It does not seem possible to block signals raise()d, using sigprocmask
and friends (i.e. the functions in System.Posix.Signals). The same was
true for C test programs. This program blocks SIGUSR1 when compiled
normally, but doesn't block the signal when compiled with -pthread.

        paprika$ gcc -pthread t.c
        paprika$ ./a.out 
        SIGUSR1 is blocked: 1
        zsh: user-defined signal 1  ./a.out

the testsuite test signals002 displays the same behaviour.

------------------------------------------------------------------------
        #include <signal.h>

        void f(void) {

                int i;

                /* mask off signal */
                sigset_t set, oset;
                sigemptyset(&set);
                sigaddset(&set, SIGUSR1);
                sigprocmask(SIG_BLOCK, &set, NULL);

                /* check if it is supposed to be blocked */
                sigprocmask(0, NULL, &oset);
                printf("SIGUSR1 is blocked: %d\n",  sigismember( &oset, SIGUSR1) );

                /* raise the signal */
                raise(SIGUSR1);

                /* did we survive? */
                sigpending(&oset);
                printf("we blocked SIGUSR1: %d\n",  sigismember( &oset, SIGUSR1) );
        }

        int main() { f(); exit(0); }
------------------------------------------------------------------------

It seems that just linking this with -lpthread makes raise() not useful.
In which case it seems that I need pthread_kill( pthread_self(), sig) to
send blockable signals. This situation is the case in the threaded rts,
which is why lib/Posix/signals002.hs was failing on OpenBSD.

-- Don
_______________________________________________
Cvs-ghc mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to