From de3e453f838d9f5f4282eca1e9dc126b5604a376 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Sat, 23 Aug 2008 00:42:18 +0000 Subject: [PATCH] 2008-08-22 Miguel de Icaza * console-io.c (sigcont_handler): Support signal chaining for SIGCONT. (console_set_signal_handlers): Use best practices with sigaction, clear the structure before using it. svn path=/trunk/mono/; revision=111454 --- mono/metadata/ChangeLog | 8 ++++++++ mono/metadata/console-io.c | 16 ++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/mono/metadata/ChangeLog b/mono/metadata/ChangeLog index 39d6e078cc4..41e0de0d8b0 100644 --- a/mono/metadata/ChangeLog +++ b/mono/metadata/ChangeLog @@ -1,3 +1,11 @@ +2008-08-22 Miguel de Icaza + + * console-io.c (sigcont_handler): Support signal chaining for + SIGCONT. + + (console_set_signal_handlers): Use best practices with sigaction, + clear the structure before using it. + 2008-08-22 Robert Jordan * console-io.c (ves_icall_System_ConsoleDriver_TtySetup): diff --git a/mono/metadata/console-io.c b/mono/metadata/console-io.c index 08b435ac713..5b27b95bada 100644 --- a/mono/metadata/console-io.c +++ b/mono/metadata/console-io.c @@ -262,25 +262,33 @@ sigint_handler (int signo) in_sigint = FALSE; } +static struct sigaction save_sigcont, save_sigint; + static void -sigcont_handler (int signo) +sigcont_handler (int signo, void *the_siginfo, void *data) { // Ignore error, there is not much we can do in the sigcont handler. tcsetattr (STDIN_FILENO, TCSANOW, &mono_attr); if (keypad_xmit_str != NULL) write (STDOUT_FILENO, keypad_xmit_str, strlen (keypad_xmit_str)); -} -static struct sigaction save_sigcont, save_sigint; + if (save_sigcont.sa_sigaction != NULL && + save_sigcont.sa_sigaction != (void *)SIG_DFL && + save_sigcont.sa_sigaction != (void *)SIG_IGN) + (*save_sigcont.sa_sigaction) (signo, the_siginfo, data); +} void console_set_signal_handlers () { struct sigaction sigcont, sigint; + memset (&sigcont, 0, sizeof (struct sigaction)); + memset (&sigint, 0, sizeof (struct sigaction)); + // Continuing - sigcont.sa_handler = sigcont_handler; + sigcont.sa_handler = (void *) sigcont_handler; sigcont.sa_flags = 0; sigemptyset (&sigcont.sa_mask); sigaction (SIGCONT, &sigcont, &save_sigcont); -- 2.25.1