This looks OK. Everything is still public enough where a user application can register their own <ctl>-C catching function at that level.
Thanks for doing this. --joel On Thu, May 7, 2020 at 1:52 AM Sebastian Huber < sebastian.hu...@embedded-brains.de> wrote: > Merge the rtems_termios_isig_status_code and > rtems_termios_iproc_status_code enums into a single > rtems_termios_iproc_status_code which is now a part of the API. > > Simplify rtems_termios_posix_isig_handler() to avoid unreachable code. > > Close #3800. > --- > cpukit/include/rtems/libio.h | 47 > +++++++++++++--------- > cpukit/libcsupport/src/termios.c | 34 ++-------------- > .../libcsupport/src/termios_posix_isig_handler.c | 18 ++++----- > 3 files changed, 40 insertions(+), 59 deletions(-) > > diff --git a/cpukit/include/rtems/libio.h b/cpukit/include/rtems/libio.h > index b3c0e975cd..f1c9eea51b 100644 > --- a/cpukit/include/rtems/libio.h > +++ b/cpukit/include/rtems/libio.h > @@ -1904,28 +1904,37 @@ rtems_status_code rtems_termios_bufsize ( > ); > > /** > - * @brief Type returned by all input processing (isig) methods > - */ > + * @brief The status code returned by all Termios input processing (iproc) > + * functions and input signal (isig) handlers. > + */ > typedef enum { > /** > - * This indicates that the input character was processed > - * and possibly placed into the buffer. > + * @brief This status indicates that the input processing can continue. > + * > + * Input signal handlers shall return this status if no signal was > raised and > + * the input processing can continue. > */ > - RTEMS_TERMIOS_ISIG_WAS_PROCESSED, > + RTEMS_TERMIOS_IPROC_CONTINUE, > + > /** > - * This indicates that the input character was not processed and > - * subsequent processing is required. > + * @brief This status indicates that the input processing should stop > due to > + * a signal. > + * > + * This indicates that the character was processed and determined to be > one > + * that requires a signal to be raised (e.g. VINTR or VKILL). The tty > must > + * be in the right Termios mode for this to occur. There is no further > + * processing of this character required and the pending read() > operation > + * should be interrupted. > */ > - RTEMS_TERMIOS_ISIG_WAS_NOT_PROCESSED, > + RTEMS_TERMIOS_IPROC_INTERRUPT, > + > /** > - * This indicates that the character was processed and determined > - * to be one that requires a signal to be raised (e.g. VINTR or > - * VKILL). The tty must be in the right termios mode for this to > - * occur. There is no further processing of this character required and > - * the pending read() operation should be interrupted. > + * @brief This status indicates that the input processing is done. > + * > + * This status shall not be returned by input processing signal > handlers. > */ > - RTEMS_TERMIOS_ISIG_INTERRUPT_READ > -} rtems_termios_isig_status_code; > + RTEMS_TERMIOS_IPROC_DONE > +} rtems_termios_iproc_status_code; > > /** > * @brief Type for ISIG (VINTR/VKILL) handler > @@ -1941,9 +1950,9 @@ typedef enum { > * @param tty termios structure pointer for this input tty > * > * @return The value returned is according to that documented > - * for @ref rtems_termios_isig_status_code. > + * for @ref rtems_termios_iproc_status_code. > */ > -typedef rtems_termios_isig_status_code (*rtems_termios_isig_handler)( > +typedef rtems_termios_iproc_status_code (*rtems_termios_isig_handler)( > unsigned char c, > struct rtems_termios_tty *tty > ); > @@ -1966,7 +1975,7 @@ typedef rtems_termios_isig_status_code > (*rtems_termios_isig_handler)( > * @return The value returned is according to that documented > * for all methods adhering to @ref rtems_termios_isig_handler. > */ > -rtems_termios_isig_status_code rtems_termios_default_isig_handler( > +rtems_termios_iproc_status_code rtems_termios_default_isig_handler( > unsigned char c, > struct rtems_termios_tty *tty > ); > @@ -1984,7 +1993,7 @@ rtems_termios_isig_status_code > rtems_termios_default_isig_handler( > * @return The value returned is according to that documented > * for all methods adhering to @ref rtems_termios_isig_handler. > */ > -rtems_termios_isig_status_code rtems_termios_posix_isig_handler( > +rtems_termios_iproc_status_code rtems_termios_posix_isig_handler( > unsigned char c, > struct rtems_termios_tty *tty > ); > diff --git a/cpukit/libcsupport/src/termios.c > b/cpukit/libcsupport/src/termios.c > index 3690ee3fc3..75925cf8ec 100644 > --- a/cpukit/libcsupport/src/termios.c > +++ b/cpukit/libcsupport/src/termios.c > @@ -1311,12 +1311,12 @@ static rtems_termios_isig_handler > termios_isig_handler = > * This is the default method to process VKILL or VQUIT characters if > * ISIG processing is enabled. Note that it does nothing. > */ > -rtems_termios_isig_status_code rtems_termios_default_isig_handler( > +rtems_termios_iproc_status_code rtems_termios_default_isig_handler( > unsigned char c, > struct rtems_termios_tty *tty > ) > { > - return RTEMS_TERMIOS_ISIG_WAS_NOT_PROCESSED; > + return RTEMS_TERMIOS_IPROC_CONTINUE; > } > > /* > @@ -1335,28 +1335,6 @@ rtems_status_code > rtems_termios_register_isig_handler( > return RTEMS_SUCCESSFUL; > } > > -/** > - * @brief Type returned by all input processing (iproc) methods > - */ > -typedef enum { > - /** > - * This indicates that the input processing can continue. > - */ > - RTEMS_TERMIOS_IPROC_CONTINUE, > - /** > - * This indicates that the input processing is done. > - */ > - RTEMS_TERMIOS_IPROC_DONE, > - /** > - * This indicates that the character was processed and determined > - * to be one that requires a signal to be raised (e.g. VINTR or > - * VKILL). The tty must be in the right termios mode for this to > - * occur. There is no further processing of this character required and > - * the pending read() operation should be interrupted. > - */ > - RTEMS_TERMIOS_IPROC_INTERRUPT > -} rtems_termios_iproc_status_code; > - > /* > * Process a single input character > */ > @@ -1369,13 +1347,7 @@ iproc (unsigned char c, struct rtems_termios_tty > *tty) > */ > if ((tty->termios.c_lflag & ISIG)) { > if ((c == tty->termios.c_cc[VINTR]) || (c == > tty->termios.c_cc[VQUIT])) { > - rtems_termios_isig_status_code rc; > - rc = (*termios_isig_handler)(c, tty); > - if (rc == RTEMS_TERMIOS_ISIG_INTERRUPT_READ) { > - return RTEMS_TERMIOS_IPROC_INTERRUPT; > - } > - > - return RTEMS_TERMIOS_IPROC_CONTINUE; > + return (*termios_isig_handler)(c, tty); > } > } > > diff --git a/cpukit/libcsupport/src/termios_posix_isig_handler.c > b/cpukit/libcsupport/src/termios_posix_isig_handler.c > index 5be2d10aa2..5f505fecb4 100644 > --- a/cpukit/libcsupport/src/termios_posix_isig_handler.c > +++ b/cpukit/libcsupport/src/termios_posix_isig_handler.c > @@ -20,20 +20,20 @@ > > #include <signal.h> > > -rtems_termios_isig_status_code rtems_termios_posix_isig_handler( > +rtems_termios_iproc_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; > - } > + int sig; > > - if (c == tty->termios.c_cc[VQUIT]) { > - raise(SIGQUIT); > - return RTEMS_TERMIOS_ISIG_INTERRUPT_READ; > + if ( c == tty->termios.c_cc[ VQUIT ] ) { > + sig = SIGQUIT; > + } else { > + sig = SIGINT; > } > > - return RTEMS_TERMIOS_ISIG_WAS_NOT_PROCESSED; > + (void) raise( sig ); > + > + return RTEMS_TERMIOS_IPROC_INTERRUPT; > } > -- > 2.16.4 > > _______________________________________________ > devel mailing list > devel@rtems.org > http://lists.rtems.org/mailman/listinfo/devel >
_______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel