Simplify the SIGTSTP handler to let it work with uthreads.

Suspending multithreaded programs built with ghc (including ghc
itself) should just work[tm] now. (Except for the bootstrapping
compiler which of course still uses the old code)
This commit is contained in:
kili 2011-12-27 20:53:01 +00:00
parent 9f9c183181
commit c1cbe21efb
2 changed files with 56 additions and 2 deletions

View File

@ -1,11 +1,11 @@
# $OpenBSD: Makefile,v 1.61 2011/10/26 19:34:08 kili Exp $
# $OpenBSD: Makefile,v 1.62 2011/12/27 20:53:01 kili Exp $
COMMENT-main = compiler for the functional language Haskell
COMMENT-doc = documentation for GHC
DISTNAME = ghc-${MODGHC_VER}
PKGNAME-main = ghc-${MODGHC_VER}
REVISION-main = 1
REVISION-main = 2
PKGNAME-doc = ghc-doc-${MODGHC_VER}
CATEGORIES = lang devel
HOMEPAGE = http://www.haskell.org/ghc/

View File

@ -0,0 +1,54 @@
$OpenBSD: patch-rts_posix_Signals_c,v 1.1 2011/12/27 20:53:01 kili Exp $
There are several problems with the original code:
- It doesn't work with uthreads (instead of running the default
handler, the custom handler is called again, which causes an
endless cascade of signals once the process gets a SIGTSTP).
- It isn't posix compliant (sigprocmask(2) behaviour is unspecified for
multithreaded processes, where you would have to use
pthread_sigmask(3)).
- It's far too complicated compared to the simple kill(getpid(),
SIGSTOP).
--- rts/posix/Signals.c.orig Mon Jun 13 19:10:06 2011
+++ rts/posix/Signals.c Tue Dec 27 19:58:52 2011
@@ -494,7 +494,7 @@ empty_handler (int sig STG_UNUSED)
The trick we use is:
- catch SIGTSTP
- - in the handler, kill(getpid(),SIGTSTP)
+ - in the handler, kill(getpid(),SIGSTOP)
- when this returns, restore the TTY settings
This means we don't have to catch SIGCONT too.
@@ -516,17 +516,8 @@ sigtstp_handler (int sig)
}
}
- // de-install the SIGTSTP handler
- set_sigtstp_action(rtsFalse);
-
// really stop the process now
- {
- sigset_t mask;
- sigemptyset(&mask);
- sigaddset(&mask, sig);
- sigprocmask(SIG_UNBLOCK, &mask, NULL);
- kill(getpid(), sig);
- }
+ kill(getpid(), SIGSTOP);
// on return, restore the TTY state
for (fd = 0; fd <= 2; fd++) {
@@ -534,8 +525,6 @@ sigtstp_handler (int sig)
tcsetattr(0,TCSANOW,&ts[fd]);
}
}
-
- set_sigtstp_action(rtsTrue);
}
static void