Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Alexis King
GHC
Commits
0095702d
Commit
0095702d
authored
Jan 03, 2012
by
Simon Marlow
Browse files
In the SIGTSTP handler, throw SIGSTOP instead of re-throwing SIGTSTP
parent
aa1114ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
rts/posix/Signals.c
View file @
0095702d
...
...
@@ -519,17 +519,28 @@ empty_handler (int sig STG_UNUSED)
The trick we use is:
- catch SIGTSTP
- in the handler, kill(getpid(),SIG
T
STP)
- in the handler, kill(getpid(),SIGST
O
P)
- 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
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 +561,6 @@ sigtstp_handler (int sig)
tcsetattr
(
0
,
TCSANOW
,
&
ts
[
fd
]);
}
}
set_sigtstp_action
(
rtsTrue
);
}
static
void
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment