Open wizche opened 4 days ago
The TMUX/Screen interaction can indeed be a little finicky. It seemed to work fine on my end and I already experimented with some sleeps before but wasn’t quite satisfied with my approach. Happy to review a PR regarding that as well
What I do now is send a tmux send-keys -t $SESSION_NAME:$WINDOW_NAME "" C-m
before the actual afl-fuzz command, that seems to fix the problem in my case.
Here some ChatGPT suggestions:
Set a flag in .bashrc
# Signal that the shell is ready for tmux commands
if [ -n "$TMUX" ]; then
tmux wait-for -S shell_ready
fi
And wait for it: tmux wait-for shell_ready
Read the content from the session until it makes sense:
# Start a new tmux session
tmux new-session -d -s mysession
check_pane_ready() { tmux send-keys -t mysession "pwd" C-m # Run a harmless command sleep 0.1 # Small delay to give tmux time to process
last_output=$(tmux capture-pane -t mysession -p -S -1)
# Check if the output of 'pwd' was captured (or other suitable prompt check)
[[ -n "$last_output" ]]
}
until check_pane_ready; do sleep 0.1 # Retry interval done
---
Not sure which want you wanna go, maybe keeping a sleep is enough?
We don't actually care if the whole campaign start is delayed for a second.
We don't actually care if the whole campaign start is delayed for a second. That's what I'm thinking. If there's a significant delay upon startup, it should be communicated to the user so (like a visual indicator or whatever).
I think either solution could work. Something that checks for a sane state/output before continuing seems reasonable and good to debug if we need to make further adjustments eventually if this keeps being a problem.
Resulting in the instance not starting properly. maybe should we add a sleep?