You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
Update version in Makefile to v0.1.0
Run integration env
Call the /update endpoint (curl -k -X POST http://localhost:8000/api/visors/03374f658c7107071ae35fc1d030e926fb99e461dd13662988d1306cb823ab05d4/update)
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.
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 likeCTRL-C
.Steps to Reproduce
Steps to reproduce the behavior:
Makefile
tov0.1.0
/update
endpoint (curl -k -X POST http://localhost:8000/api/visors/03374f658c7107071ae35fc1d030e926fb99e461dd13662988d1306cb823ab05d4/update
)CTRL-C
. It will remain run (checkps 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 hasS+
attributes, after that, it hasS
, 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 ofexec.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
The text was updated successfully, but these errors were encountered: