Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-ss option and --log does not work correctly sometimes. #95

Closed
greymd opened this issue Jul 31, 2018 · 6 comments
Closed

-ss option and --log does not work correctly sometimes. #95

greymd opened this issue Jul 31, 2018 · 6 comments
Labels

Comments

@greymd
Copy link
Owner

greymd commented Jul 31, 2018

Reproduced Environment:
Docker on macOS 10.12.06 Sierra + Docker(18.06.0-ce-mac70)
container: ubuntu:18.04
tmux version: 2.4
bash version: 3.2.0

$ xpanes --debug -ss --log=~/logs --log-format="[:ARG:]" -I@ -d -c "echo TEST | sed s/TEST/@/" AAAA BBBB CCCC DDDD

# Expected
## ~/logs/AAAA-1 => AAAA
## ~/logs/BBBB-1 => BBBB
## ~/logs/CCCC-1 => CCCC
## ~/logs/DDDD-1 => DDDD

# Actual (sometimes)
## ~/logs/AAAA-1 => AAAA
## ~/logs/BBBB-1 => BBBB
## ~/logs/CCCC-1 => !!EMPTY!!
## ~/logs/DDDD-1 => DDDD

# $ cat ~/logs/CCCC-1
# => nothing

Same problem seems happened on the TravisCI link.

tmux pipe-pane is used for the logging feature of tmux-xpanes.
During the development for version 3.1.0, I noticed, the logging feature does not work correctly sometimes.
It seems that, running multiple pipe-pane processes does not work correctly.

Here is PoC.

  1. Creating multiple named pipes.
  2. Split tmux panes and start the processes to wait each named pipe updated.
  3. Run tmux pipe-pane to redirect each pane's stdout.
  4. Notify all the named pipes.
  5. Some results of the pipe-pane is empty. Frequently.
#!/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 <<<<<<<<<<<<<<<<<<< EMPTY !!!
# /home/docker/work/D.log <<<<<<<<<<<<<<<<<<< EMPTY !!!
@greymd
Copy link
Owner Author

greymd commented Jul 31, 2018

Even sleep command is inserted any part, the problem is reproduced..

@greymd
Copy link
Owner Author

greymd commented Jul 31, 2018

It seems that, this is caused by https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=865756

@greymd
Copy link
Owner Author

greymd commented Jul 31, 2018

Same issue does not reproduced in tmux 2.7.
Therefore, it would be known bug in tmux.
(--log feature does not work in tmux 2.3 due to Known Bug. That's why status is green.)

@greymd greymd changed the title Logging feature does not work correctly sometimes on docker container. -s option and --log does not work correctly sometimes on docker container. Aug 1, 2018
@greymd greymd changed the title -s option and --log does not work correctly sometimes on docker container. -ss option and --log does not work correctly sometimes on docker container. Aug 1, 2018
@greymd
Copy link
Owner Author

greymd commented Aug 1, 2018

This issue seems fixed in tmux 2.6 and more.
https://travis-ci.org/greymd/tmux-xpanes/builds/410575182

@greymd greymd added the bug label Aug 1, 2018
@greymd
Copy link
Owner Author

greymd commented Aug 1, 2018

Let me update Known Bug page.
/~https://github.com/greymd/tmux-xpanes/wiki/Known-Bugs

@greymd greymd changed the title -ss option and --log does not work correctly sometimes on docker container. -ss option and --log does not work correctly sometimes. Aug 1, 2018
@greymd
Copy link
Owner Author

greymd commented Aug 2, 2018

Fixed at v3.1.0

@greymd greymd closed this as completed Aug 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant