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

Do not exit on EOF #45

Merged
merged 2 commits into from Jan 5, 2017
Merged

Do not exit on EOF #45

merged 2 commits into from Jan 5, 2017

Commits on Nov 7, 2016

  1. Do not exit on EOF

    Forward the EOF to GoTTY, and let the server-side decide if it wants to
    terminate the connection. The server closes the connection, and in
    response we terminate the readLoop which in turn signals writeLoop to
    terminate via the QuitChan.
    
    This allows for the user to pipe commands to gotty-client, and capture
    all the result sent by the server. For eg. when gotty is launched as
    `gotty -w bash`, the following command would now wait to capture all
    output from the server.
    
    for (( i = 0 ; i < 2; ++i )); do echo echo $i; echo sleep 2; done | ./gotty-client https://gotty.example.com
    
    Before this patch, gotty-client used to exit on encountering EOF from
    the left side of the pipe.
    gurjeet committed Nov 7, 2016
    Configuration menu
    Copy the full SHA
    3e895cf View commit details
    Browse the repository at this point in the history

Commits on Dec 17, 2016

  1. Implement poison-pill method to exit infinite loops

    All cooperating goroutines regularly try to read from the shared "poison"
    channel.  If the read succeeds, they exit by calling die(), assuming
    somebody else cracked open the poison pill.
    
    When any of these goroutines is done with its job, it signals other
    goroutines to exit by calling open_poison() on the shared channel.
    
    This approach takes advantage of the fact that reads from a closed
    channel always succeed.
    
    The driving goroutine (Client.Loop() in this case), is called from the
    "main" goroutine. And because when the "main" goroutine exits, the whole
    program exit (using os.Exit()) irrepective of liveness of other goroutines,
    we could not use the same "poison" channel to wait in the driving goroutine.
    
    Instead, we use sync.WaitGroup to wait for spawned goroutines, because
    we want the spawned goroutines to cleanup and exit cleanly.
    gurjeet committed Dec 17, 2016
    Configuration menu
    Copy the full SHA
    e153cff View commit details
    Browse the repository at this point in the history