bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-readline] Bug in signls.c if SIGTSTP and similars are not defined.


From: Juan Manuel Guerrero
Subject: [Bug-readline] Bug in signls.c if SIGTSTP and similars are not defined.
Date: Sat, 08 Jul 2017 15:12:16 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.13) Gecko/20101206 SUSE/3.1.7 Thunderbird/3.1.7

I am still trying to port readline to FreeDOS using DJGPP and I have found the
following signal issue.  The used system does not provide SIGTSTP and similars.
Thus it does not compile.  The interesting issue is that in function 
_rl_handle_signal
it is explicitly checked that SIGTSTP is defined, see line 222:


[snipped start]
#if defined (SIGTSTP)
    case SIGTSTP:
    case SIGTTIN:
#  if defined (HAVE_POSIX_SIGNALS)
      /* Block SIGTTOU so we can restore the terminal settings to something
         sane without stopping on SIGTTOU if we have been placed into the
         background.  Even trying to get the current terminal pgrp with
         tcgetpgrp() will generate SIGTTOU, so we don't bother.  Don't bother
         doing this if we've been stopped on SIGTTOU; it's aready too late. */
      sigemptyset (&set);
      sigaddset (&set, SIGTTOU);
      sigprocmask (SIG_BLOCK, &set, (sigset_t *)NULL);
#  endif
    case SIGTTOU:
#endif /* SIGTSTP */
[snipped end]


but later at line 250 no precaution is taken:


[snipped start]
#if defined (SIGQUIT)
    case SIGQUIT:
#endif
      rl_echo_signal_char (sig);
      rl_cleanup_after_signal ();

#if defined (HAVE_POSIX_SIGNALS)
      /* Unblock SIGTTOU blocked above */
      if (sig == SIGTTIN || sig == SIGTSTP)  <-- offending line!
        sigprocmask (SIG_UNBLOCK, &set, (sigset_t *)NULL);

      sigemptyset (&set);
      sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
      sigdelset (&set, sig);
#else /* !HAVE_POSIX_SIGNALS */
#  if defined (HAVE_BSD_SIGNALS)
      omask = sigblock (0);
#  endif /* HAVE_BSD_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
[snipped end]



It is not enough to check for HAVE_POSIX_SIGNALS.  It must also be checked
for SIGTSTP and friends as it has been done the lines before.  I have fixed
it as shown in the patch but I am not sure if it is the right form to do it.
After that fix I was able to compile to compile the readline and history
libraries with DJGPP.  Now I am checking how well the sample code performs.
Patch is against readline repository.  Hope that the hint is usefull.


Kind regards,
Juan M. Guerrero



2017-07-08  Juan Manuel Guerrero  <address@hidden>

        * signals.c (_rl_handle_signal):  Check that SIGTSTP is defined.






diff --git a/signals.c b/signals.c
index 927f532..1018ddc 100644
--- a/signals.c
+++ b/signals.c
@@ -248,6 +248,7 @@ _rl_handle_signal (sig)
       rl_cleanup_after_signal ();

 #if defined (HAVE_POSIX_SIGNALS)
+#  if defined (SIGTSTP)
       /* Unblock SIGTTOU blocked above */
       if (sig == SIGTTIN || sig == SIGTSTP)
        sigprocmask (SIG_UNBLOCK, &set, (sigset_t *)NULL);
@@ -255,6 +256,7 @@ _rl_handle_signal (sig)
       sigemptyset (&set);
       sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
       sigdelset (&set, sig);
+#  endif
 #else /* !HAVE_POSIX_SIGNALS */
 #  if defined (HAVE_BSD_SIGNALS)
       omask = sigblock (0);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]