[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] Mixing background tasks with input redirection somehow unset
From: |
João Eiras |
Subject: |
[Help-bash] Mixing background tasks with input redirection somehow unsets stty's icanon and echo |
Date: |
Thu, 22 Dec 2016 21:01:58 +0100 |
Howdy.
sorry for the lame title but I can't describe this issue simply.
I wrote a script that runs a bunch of tasks in parallel, but
serializes their output as it they had ran in sequence.
Then I hit an weird bug and minified it to a testcase (available below).
So, if run nmap in a background process (I couldn't reproduce it just
with echo and sleep) and do some input redirection, after the script
quits, the stty's options echo and icanon are off, and as expected the
terminal does not show me what I'm typing.
I can't understand what it causing the options to toggle. It's not
100% reproducible, more like 50%, and I'm a bit afraid it might be
entirely reliant how nmap behaves on my computer+home network.
Any hints ?
Thank you!
#!/bin/bash
function stty_opts {
stty --all | awk '{sep=" ";if ($0 ~ /;/)sep=";";gsub(sep,"\n",$0);print}'
}
old_options="$(stty_opts)"
set -x
# == Start Test ==
nmap "2.3.4.1" &
cat < <( nmap "2.3.4.2" ) &
wait
# == End Test ==
set +x
diff -Naur <(echo "$old_options") <(stty_opts)
- [Help-bash] Mixing background tasks with input redirection somehow unsets stty's icanon and echo,
João Eiras <=