runj icon indicating copy to clipboard operation
runj copied to clipboard

terminal discards first keypress

Open samuelkarp opened this issue 3 years ago • 5 comments

When running a container with a terminal (through ctr run --tty), the first keypress after the container starts running appears to be discarded.

samuelkarp avatar Apr 16 '21 04:04 samuelkarp

It might not be related, but FreeBSD requires TIOCSCTTY to be called by the session group leader to set the controlling console, it doesn't set the tty automatically as controlling when opening the slave terminal. (see: https://www.freebsd.org/cgi/man.cgi?query=termios&apropos=0&sektion=4&manpath=FreeBSD+13.0-current&arch=default&format=html section "Controlling terminal")

/bin/csh is also complaining about lacking a proper terminal when ran via runj (but not when I jexec into the same jail by hand)

gizahNL avatar May 07 '21 08:05 gizahNL

OK, tested it, doesn't fix the first keypress missing issue, does fix the

Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.

error spewed out by csh

gizahNL avatar May 07 '21 09:05 gizahNL

It doesn't look as if jexec does anything with the TTY, it just inherits whatever the caller had. It does take care to propagate the TERM environment variable, even if it's cleaning the environment. It is setting the user context, which may have some impact on the TTY that I don't understand (in particular, this will set the LANG, MM_CHARSET and TERM environment variables to the defaults for the login class, which may impact how csh interacts with the TTY). @gizahNL, do you see any interesting differences between the output of env when run from jexec vs runj?

davidchisnall avatar Jun 10 '21 16:06 davidchisnall

@davidchisnall The controlling terminal issue I fixed via 91402841220efd347f86db86d75a283447b195f7 unfortunately that was not the cause of the first keypress getting discarded :/

gizahNL avatar Jun 11 '21 08:06 gizahNL

I never noticed this issue using runj with buildah and podmon which might suggest the problem is upstream from runj, perhaps in the containerd shim?

dfr avatar May 26 '22 16:05 dfr