Created
February 3, 2016 18:58
-
-
Save hoytech/d3e19c6e860e224cbdd7 to your computer and use it in GitHub Desktop.
Race condition with ssh -tt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh -o ServerAliveInterval=30 -o ControlPersist=no -2MNx -S .junk_socket localhost & | |
MAINPID=$! | |
sleep 1 | |
ssh -tt -S .junk_socket localhost -- id & | |
PID1=$! | |
sleep 1 # <-- comment out this sleep to trigger race condition | |
ssh -tt -S .junk_socket localhost -- id & | |
PID2=$! | |
wait $PID1 $PID2 | |
kill $MAINPID |
As I mentioned in this Net::OpenSSH ticket:
I have given up on using -tt (tty => 1) and am making sure that sudo can function without a terminal by editing the /etc/sudoers file, see this bug:
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With Net::OpenSSH I'm passing in
{tty => 1}
tomake_remote_command
so that I can use sudo. I am seeing spurious (?) warnings likeprocess_mux_new_session: tcgetattr: Inappropriate ioctl for device
as the Net::OpenSSH docs suggest I will.However, I've noticed if I run 2 commands in parallel, I often hit a race condition where the control master dies unexpectedly. This gist is a simple shell script for reproducing this bug.
The script works reliably as is, but if you uncomment the
sleep 1
command in the middle then about 50% of the time on my box both of thessh localhost id
commands error out with broken pipes (ssh -vvv says the master dies unexpectedly).Throwing -vvv on the master ssh command line I see:
(2 requests but only one accept -- let me know if the entire output would be useful).
For now I'm trying to ensure that only 1 sudo request is running at once although this is a little bit sub-optimal.