diff options
author | Joel Sherrill <joel@rtems.org> | 2019-10-02 16:49:00 -0500 |
---|---|---|
committer | Joel Sherrill <joel@rtems.org> | 2019-10-08 14:25:41 -0500 |
commit | 667501a314ba75f80f1c13c6b43dd35d0a00efd1 (patch) | |
tree | ec786d34150d19f7aac04b2653fa356c6a696de2 /cpukit/libcsupport/src/termios_posix_isig_handler.c | |
parent | termios04/init.c: Remove dead copy of change_iflag() (diff) | |
download | rtems-667501a314ba75f80f1c13c6b43dd35d0a00efd1.tar.bz2 |
termios: Add Capability to Generate SIGINTR and SIGQUIT
This patch adds the ability for termios to send SIGINTR on receipt
of VINTR and SIGQUIT for VKILL and return -1/EINTR from read() on
a termios channel. Importantly, this patch does not alter the default
behavior or force POSIX signal code in just because termios is used.
The application must explicitly enable the POSIX behavior of generating
a signal upon receipt of these characters. This is discussed in the
POSIX standard:
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap11.html
Closes #3800.
Diffstat (limited to '')
-rw-r--r-- | cpukit/libcsupport/src/termios_posix_isig_handler.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/cpukit/libcsupport/src/termios_posix_isig_handler.c b/cpukit/libcsupport/src/termios_posix_isig_handler.c new file mode 100644 index 0000000000..105e7f463d --- /dev/null +++ b/cpukit/libcsupport/src/termios_posix_isig_handler.c @@ -0,0 +1,39 @@ +/** + * @file + * TERMIOS POSIX behavior on INTR and QUIT characters + */ + +/* + * COPYRIGHT (c) 1989-2012,2019. + * On-Line Applications Research Corporation (OAR). + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems.h> +#include <rtems/libio.h> +#include <rtems/termiostypes.h> + +#include <signal.h> + +rtems_termios_isig_status_code rtems_termios_posix_isig_handler( + unsigned char c, + struct rtems_termios_tty *tty +) +{ + if (c == tty->termios.c_cc[VINTR]) { + raise(SIGINT); + return RTEMS_TERMIOS_ISIG_INTERRUPT_READ; + } + + if (c == tty->termios.c_cc[VQUIT]) { + raise(SIGQUIT); + return RTEMS_TERMIOS_ISIG_INTERRUPT_READ; + } + + return RTEMS_TERMIOS_ISIG_WAS_NOT_PROCESSED; +} |