summaryrefslogtreecommitdiff
path: root/rc
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2022-11-05 02:57:49 +0000
committerMichael Forney <mforney@mforney.org>2022-11-05 02:57:49 +0000
commitb7cc14789adbd31e4e7334f502782feea34a8524 (patch)
treee390fe997e05facafa502a3f94e5f675b5cc33c0 /rc
parent4d1d8c342fc391cc8cf4b966a3c4f1d0c756d128 (diff)
ircrc: fix race with pipe causing hangup
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.
Diffstat (limited to 'rc')
-rwxr-xr-xrc/bin/ircrc26
1 files changed, 13 insertions, 13 deletions
diff --git a/rc/bin/ircrc b/rc/bin/ircrc
index b01a0f408..f7f829e46 100755
--- a/rc/bin/ircrc
+++ b/rc/bin/ircrc
@@ -32,28 +32,28 @@ fn etime {
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}'}
while (cmd=`{read}) {
s=$status
if(~ $s *eof) {
- echo QUIT : Leaving... > $netdir/data
+ echo QUIT : Leaving...
exit
}
msg=()
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 @@ fn work {
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 @@ if not {
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