From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 28191 invoked from network); 5 Nov 2022 03:01:13 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 5 Nov 2022 03:01:13 -0000 Received: from mail-pg1-f179.google.com ([209.85.215.179]) by 9front; Fri Nov 4 22:59:32 -0400 2022 Received: by mail-pg1-f179.google.com with SMTP id q71so5883184pgq.8 for <9front@9front.org>; Fri, 04 Nov 2022 19:59:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mforney.org; s=google; h=content-transfer-encoding:mime-version:to:subject:date:from :message-id:from:to:cc:subject:date:message-id:reply-to; bh=M+efbgvjOj/6asd8xm6jN2VTMPFe9J4aIXmIQYAwMZs=; b=TOfmpPakLCGXkM136uVi4Nl6k1KK0G2KTzWbj1KHgAasBO1dd+1dWkxjEhI33imchF VeN+cbSkJ9AUIbJI+4JiSyEtJFedzpRZJZ9WozAVRegd5CxzC6y+4SW5e1TQRZo2rY0G UwMiSM27KrSANjfhucoMJQQIqpv90IOveM5daSSiPyB/efjcKxOUAdEcuybuNdJGsphl DvTMq825h10X2HExTS9l66xHVjg3ZHEnh3RMF+1GzJZjuEzjcQVtgg8VJObgZE4+Dpl4 yaZrv0YMlwhbQW2AwKCL6up4VHSv9NUHkWlj6xM5Tawj2BKewuKb0oDJMunai+zKIpS8 4Y/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:to:subject:date:from :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=M+efbgvjOj/6asd8xm6jN2VTMPFe9J4aIXmIQYAwMZs=; b=EmV61nPwzK1sQQTp2v8OXhgVrUP+wbGK4+NRCjGnEGDf5pSS6iI6rcbCnacc8om4oS FLIC6OmmE9PEsJU73hAGVsaqUFscloeAqkcMbHTaWZaFBSX2LGa/Qi5FWP2+/fO6GNuK CME6CZrG2tw66bldvD5RvVUqS4gz3hcfMfnxaeefjV5uDP1C0NMb5a+u+ALuO/XEqXyS WRG3raCkmftQl3pvW/1zJWMwJgi5hUpg5j3ua/M1D8WZlJ2ssi9UEcTDOXvNmO1Uq7bX P3PYyeA8G1RX6rDSxNnnsf84fIXAf/19dxN92G9yKl+f66hwFt7YKD4M5V1RXv+XvCm0 xVCQ== X-Gm-Message-State: ACrzQf3XhxxSLqDMLPyn1OJpBJtJ+MRo1ryrSC+VOYyPwhKaJnumYww3 OxsH0LGaXowV4IdicLJV3kk/L3VkCVW6u9Olt2I= X-Google-Smtp-Source: AMsMyM7T4SgtS6Gwkb3N9PHUhBTsZiqP+DFy3/HQZZCbdhzJ2PCTysjxbp/q5PQzaW0/CnKfv2khuw== X-Received: by 2002:a63:62c2:0:b0:46f:eb27:911a with SMTP id w185-20020a6362c2000000b0046feb27911amr19898793pgb.298.1667617168244; Fri, 04 Nov 2022 19:59:28 -0700 (PDT) Return-Path: Received: from novus.hsd1.ca.comcast.net ([98.45.132.135]) by smtp.gmail.com with ESMTPSA id p189-20020a6229c6000000b0056c08c87196sm308043pfp.48.2022.11.04.19.59.27 for <9front@9front.org> (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Nov 2022 19:59:27 -0700 (PDT) Message-ID: From: Michael Forney Date: Sat, 05 Nov 2022 02:57:49 +0000 To: 9front@9front.org MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: progressive element pipelining control Subject: [9front] [PATCH] ircrc: fix race with pipe causing hangup Reply-To: 9front@9front.org Precedence: bulk If the work function opens and closes $netdir/data for an echo redirection *before* the asynchronous cat process opens it, aux/trampoline (or tlsclient) will receive a hangup, terminating the connection. To fix this, redirect work's stdout to $netdir/data so that it remains open, and adjust the echo commands accordingly. --- diff ccf20e5a2a7c14b2016de1fe0612e272bad693dd 04b541668a06e85ce350ae81f2b0c8a2dd575f56 --- a/rc/bin/ircrc +++ b/rc/bin/ircrc @@ -32,14 +32,14 @@ fn work { if(~ $#serverpass 1) - echo PASS $serverpass > $netdir/data - echo USER $user foo bar :$realname > $netdir/data - echo NICK $nick > $netdir/data + echo PASS $serverpass + echo USER $user foo bar :$realname + echo NICK $nick if (~ $#pass 1) - echo PRIVMSG 'nickserv :'identify $"pass > $netdir/data + echo PRIVMSG 'nickserv :'identify $"pass if(! ~ $target ''){ title - echo JOIN $target > $netdir/data + echo JOIN $target } if(~ $target *,*) target = `{echo $target | awk -F',' '{print $NF}'} @@ -46,7 +46,7 @@ while (cmd=`{read}) { s=$status if(~ $s *eof) { - echo QUIT : Leaving... > $netdir/data + echo QUIT : Leaving... exit } msg=() @@ -53,7 +53,7 @@ out=() switch ($cmd(1)) { case /! - eval `{mshift $cmd} | while(rc=`{read})echo 'PRIVMSG '^$target^' :' $rc | tee $netdir/data + eval `{mshift $cmd} | while(rc=`{read})echo 'PRIVMSG '^$target^' :' $rc | tee /dev/cons case /M msg = (MODE `{mshift $cmd}) case /N @@ -101,18 +101,18 @@ case /w msg = (WHO `{mshift $cmd}) case /x - echo QUIT : Leaving... > $netdir/data + echo QUIT : Leaving... exit case /* - echo unknown command + echo unknown command >/dev/cons case * msg = 'PRIVMSG '^$target^' :'^$"cmd out = '('^$target^') ⇐ '^$"cmd } if (! ~ $#msg 0) - echo $msg > $netdir/data + echo $msg if (! ~ $#out 0) - echo `{etime}^' '^$out + echo `{etime}^' '^$out >/dev/cons } } @@ -248,6 +248,6 @@ tlsclient tcp!$server!$port <>$p/data1 >[1=0] & } netdir=$p -cat $netdir/data | tr -d '\x2\x8\xd\x1f' | pretty & -work +<$netdir/data tr -d '\x2\x8\xd\x1f' | pretty & +>$netdir/data work