Commit 0095702d authored by Simon Marlow's avatar Simon Marlow
Browse files

In the SIGTSTP handler, throw SIGSTOP instead of re-throwing SIGTSTP

parent aa1114ed
......@@ -519,17 +519,28 @@ 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.
Note we don't re-throw SIGTSTP, we throw SIGSTOP instead. This is
for a few reasons:
- re-throwing SIGTSTP would require temporarily restoring the
default sigaction.
- it doesn't work on certain buggy pthread implementations
(e.g. OpenBSD).
- throwing SIGTSTP seems slightly dodgy anyway.
-------------------------------------------------------------------------- */
static void sigtstp_handler(int sig);
static void set_sigtstp_action (rtsBool handle);
static void
sigtstp_handler (int sig)
sigtstp_handler (int sig STG_UNUSED)
int fd;
struct termios ts[3];
......@@ -541,17 +552,8 @@ sigtstp_handler (int sig)
// de-install the SIGTSTP handler
// really stop the process now
sigset_t 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 +561,6 @@ sigtstp_handler (int sig)
static void
Supports Markdown
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