summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2002-11-10 20:15:54 +0000
committerJim Meyering <jim@meyering.net>2002-11-10 20:15:54 +0000
commitf549fc269c27d5cde120aa4880d39b850b0dc97d (patch)
tree6193e92d88f3609cb2cc92225c094436987f5c61 /src
parent7acacbf29a946ea9116e99a2c24de38e4e85cfb2 (diff)
downloadcoreutils-f549fc269c27d5cde120aa4880d39b850b0dc97d.tar.xz
(sighandler): Handle SIGTSTP specially.
Based on suggestions from Solar Designer and Dmitry V. Levin. Add comments.
Diffstat (limited to 'src')
-rw-r--r--src/ls.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/ls.c b/src/ls.c
index 4e7bb2abd..f562241a9 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -1004,6 +1004,8 @@ restore_default_color (void)
put_indicator_direct (&color_indicator[C_RIGHT]);
}
+/* Upon interrupt, suspend, hangup, etc. ensure that the
+ terminal text color is restored to the default. */
static void
sighandler (int sig)
{
@@ -1013,18 +1015,26 @@ sighandler (int sig)
restore_default_color ();
+ /* SIGTSTP is special, since the application can receive that signal more
+ than once. In this case, don't set the signal handler to the default.
+ Instead, just raise the uncatchable SIGSTOP. */
+ if (sig == SIGTSTP)
+ {
+ sig = SIGSTOP;
+ }
+ else
+ {
#ifdef SA_NOCLDSTOP
- {
- struct sigaction sigact;
+ struct sigaction sigact;
- sigact.sa_handler = SIG_DFL;
- sigemptyset (&sigact.sa_mask);
- sigact.sa_flags = 0;
- sigaction (sig, &sigact, NULL);
- }
+ sigact.sa_handler = SIG_DFL;
+ sigemptyset (&sigact.sa_mask);
+ sigact.sa_flags = 0;
+ sigaction (sig, &sigact, NULL);
#else
- signal (sig, SIG_DFL);
+ signal (sig, SIG_DFL);
#endif
+ }
raise (sig);
}