Skip to content

Instantly share code, notes, and snippets.

@greymd
Last active July 31, 2018 23:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save greymd/d70c226b7880b1812d3447156b3a4af6 to your computer and use it in GitHub Desktop.
Docker + fifo + tmux bug ?
#!/bin/bash
# Try this script on the docker container.
# Tested on macoOS High Sierra + Ubuntu 18.04 docker container.
rm -f "$HOME"/work/*
tmux -S "$HOME"/work/sess new-session -d
printf "%s\\n" A B C D | while read -r f;do
mkfifo "$HOME/work/$f"
echo "start to wait: mkfifo $HOME/work/$f"
_pane_id=$( tmux -S "$HOME"/work/sess splitw -P "grep -q 1 $HOME/work/$f"$'\n'"echo 'This is $f'" )
echo "start logging: pipe-pane cat >> $HOME/work/$f.log"
tmux -S "$HOME"/work/sess pipe-pane -t "$_pane_id" "cat >> $HOME/work/$f.log"
done
printf "%s\\n" A B C D | while read -r f;do
echo "notify to $f"
printf "%s\\n" 1 > "$HOME/work/$f" &
done
sleep 5
printf "%s\\n" "$HOME/work"/*.log | while read -r file;do
echo "$file"
cat "$file"
done
# $ bash fifo.sh
# start to wait: mkfifo /home/docker/work/A
# start logging: pipe-pane cat >> /home/docker/work/A.log
# start to wait: mkfifo /home/docker/work/B
# start logging: pipe-pane cat >> /home/docker/work/B.log
# start to wait: mkfifo /home/docker/work/C
# start logging: pipe-pane cat >> /home/docker/work/C.log
# start to wait: mkfifo /home/docker/work/D
# start logging: pipe-pane cat >> /home/docker/work/D.log
# notify to A
# notify to B
# notify to C
# notify to D
# /home/docker/work/A.log
# This is A
# /home/docker/work/B.log
# This is B
# /home/docker/work/C.log <<<<<<<<<<<<<<<<<<< WTF !?
# /home/docker/work/D.log <<<<<<<<<<<<<<<<<<< WTF !?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment