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

Visor does not receive terminal commands after update #336

Closed
nkryuchkov opened this issue Apr 20, 2020 · 1 comment · Fixed by #510
Closed

Visor does not receive terminal commands after update #336

nkryuchkov opened this issue Apr 20, 2020 · 1 comment · Fixed by #510
Labels
bug Something isn't working

Comments

@nkryuchkov
Copy link
Contributor

Describe the bug
After updating via the /update endpoint, the visor runs a new binary with the same stdin/out/err. However, the new binary cannot receive terminal commands like CTRL-C.

Steps to Reproduce
Steps to reproduce the behavior:

  1. Update version in Makefile to v0.1.0
  2. Run integration env
  3. Call the /update endpoint (curl -k -X POST http://localhost:8000/api/visors/03374f658c7107071ae35fc1d030e926fb99e461dd13662988d1306cb823ab05d4/update)
  4. After the update, try to kill a new process with CTRL-C. It will remain run (check ps aux | grep visor).

Actual behavior
Visor remains run after CTRL-C.

Expected behavior
Visor stops after CTRL-C.

Additional context
The signal is not received because a new process is not attached to the same controlling terminal (CTTY). This can be checked by ps aux after the update. Before the update, the visor has S+ attributes, after that, it has S, which means it's not attached to a CTTY.

Possible implementation
We need to set the same CTTY for a new process, which can be set via SysProcAttr field of exec.Cmd. However, from what I've found, it's impossible to set the same CTTY from the parent process. So we need to find some workarounds.

The following links might help to implement the desired behavior.
https://blog.nelhage.com/2011/02/changing-ctty/
https://blog.habets.se/2009/03/Moving-a-process-to-another-terminal.html
https://linux.die.net/man/4/tty_ioctl (TIOCSCTTY)
golang/go#20454
https://github.com/google/goexpect/blob/master/expect.go#L929
golang/go#29458
https://stackoverflow.com/questions/593724/redirect-stderr-stdout-of-a-process-after-its-been-started-using-command-lin
https://unix.stackexchange.com/questions/31824/how-do-i-attach-a-terminal-to-a-detached-process
https://www.gnu.org/software/libc/manual/html_node/Job-Control.html

@nkryuchkov nkryuchkov added the bug Something isn't working label Apr 20, 2020
@jdknives
Copy link
Member

jdknives commented May 1, 2020

Related to #350

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants