b2e79ee47e
Most of the -nopie changes are from pascal@ (thanks); I only had to merge them for ghc-7.4 and tweak configure and mk/config.mk.in.
55 lines
1.5 KiB
Plaintext
55 lines
1.5 KiB
Plaintext
$OpenBSD: patch-rts_posix_Signals_c,v 1.2 2012/09/02 19:53:46 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 Wed Feb 1 19:10:32 2012
|
|
+++ rts/posix/Signals.c Sat Jun 9 21:36:25 2012
|
|
@@ -519,7 +519,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.
|
|
|
|
@@ -541,17 +541,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++) {
|
|
@@ -559,8 +550,6 @@ sigtstp_handler (int sig)
|
|
tcsetattr(0,TCSANOW,&ts[fd]);
|
|
}
|
|
}
|
|
-
|
|
- set_sigtstp_action(rtsTrue);
|
|
}
|
|
|
|
static void
|