bug-bash
[Top][All Lists]
Advanced

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

Re: bash passes changed termios to backgrounded process(es) groups?


From: Chet Ramey
Subject: Re: bash passes changed termios to backgrounded process(es) groups?
Date: Wed, 28 Aug 2024 09:04:58 -0400
User-agent: Mozilla Thunderbird

On 8/27/24 7:46 PM, Steffen Nurpmeso wrote:
Hello.

I got a bug report for my mailer which stated

    $ ( echo blah | Mail root ) &
   [1] 2754649
    $ ^M^M^M^M^C^C

   [1]+  Stopped                 ( echo blah | Mail root )
    $ fg
   ( echo blah | Mail root )
    $

I turns out i answered him now

   The thing is that if i apply the patch (this to [master])

     diff --git a/src/mx/termios.c b/src/mx/termios.c
     index 733974ebce..08dd045226 100644
     --- a/src/mx/termios.c
     +++ b/src/mx/termios.c
     @@ -152,6 +152,8 @@ a_termios_norm_query(void){
               &a_termios_g.tiosg_normal->tiose_state) == 0);
         /* XXX always set ECHO and ICANON in our "normal" canonical state */
         a_termios_g.tiosg_normal->tiose_state.c_lflag |= ECHO | ICANON;
     +   a_termios_g.tiosg_normal->tiose_state.c_iflag |= ICRNL;
     +
         /*NYD2_OU;*/
         return rv;
      }

   then everything is working as should in an otherwise unchanged MUA.
   It seems readline does this:

     ./lib/sh/shtty.c:  ttp->c_iflag |= ICRNL;       /* make sure we get CR->NL 
on input */
     ./lib/readline/rltty.c:  tiop->c_iflag &= ~(ICRNL | INLCR);

..and it seems that if bash starts a normal process then ICRNL is
set, but if it starts a (process)& or only process&, then not!
(I was about to send this to bug-readline first.)

Under no circumstances should a background process attempt to fetch or
modify terminal attributes. Why isn't your Mail process checking for that?
Chances are excellent that it will fetch the terminal attributes as they've
been set by readline when it goes to read the next command, then modify (?)
them out from underneath readline.


--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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