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

CHE-3216: Fix kill terminal process and its children on closing terminal. #3395

Merged
merged 1 commit into from
Jan 11, 2017

Conversation

AndrienkoAleksandr
Copy link
Contributor

@AndrienkoAleksandr AndrienkoAleksandr commented Dec 14, 2016

What does this PR do?

Create new type websocket message to realise ability to kill terminal process and its child processes when user click "close button".

What issues does this PR fix or reference?

#3216

@evoevodin and @garagatyi review please.

Signed-off-by: Aleksandr Andrienko aandrienko@codenvy.com

@codenvy-ci
Copy link

@codenvy-ci
Copy link

Copy link

@garagatyi garagatyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Please address my comments.

@@ -215,13 +215,12 @@ public void onError() {
}

/**
* Sends 'exit' command on server side to stop terminal.
* Sends 'kill' command on server side to stop terminal.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually closes terminal

*/
public void stopTerminal() {
if (connected) {
Jso jso = Jso.create();
jso.addField("type", "data");
jso.addField("data", "exit\n");
jso.addField("type", "kill");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename to close

if !finalizer.fileClosed {
file.Close()
finalizer.fileClosed = true
fmt.Println("Pty file closed.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also log if closing failes

@@ -141,6 +159,10 @@ func sendConnectionInputToPty(conn *websocket.Conn, reader io.ReadCloser, f *os.
log.Printf("Invalid message %s\n", err)
continue
}
if msg.Type == "kill" {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename to close

@@ -141,6 +159,10 @@ func sendConnectionInputToPty(conn *websocket.Conn, reader io.ReadCloser, f *os.
log.Printf("Invalid message %s\n", err)
continue
}
if msg.Type == "kill" {
wp.Stop(finalizer);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename to close

)

type wsPty struct {
Cmd *exec.Cmd // pty builds on os.exec
PtyFile *os.File // a pty is simply an os.File
}

func (wp *wsPty) Stop(finalizer *ReadWriteRoutingFinalizer) {
closeFile(wp.PtyFile, finalizer)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment this function well as it is not obvious and we will forget why it is implemented in such a way

@codenvy-ci
Copy link

…nal.

Signed-off-by: Aleksandr Andrienko <aandrienko@codenvy.com>
@AndrienkoAleksandr
Copy link
Contributor Author

ci-build

@codenvy-ci
Copy link

@AndrienkoAleksandr AndrienkoAleksandr merged commit 53f77e2 into master Jan 11, 2017
@AndrienkoAleksandr AndrienkoAleksandr deleted the CHE-3216 branch January 11, 2017 15:21
JPinkney pushed a commit to JPinkney/che that referenced this pull request Aug 17, 2017
…nal. (eclipse-che#3395)

Signed-off-by: Aleksandr Andrienko <aandrienko@codenvy.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants