google / gvisor

Application Kernel for Containers
https://gvisor.dev
Apache License 2.0
15.57k stars 1.28k forks source link

emacs fails with "Could not open file: /dev/tty" #10925

Open chetan-reddy opened 3 days ago

chetan-reddy commented 3 days ago

Description

When I run docker run -it --rm --network=none silex/emacs , I get a working instance of emacs. But when I try with runsc , it fails immediately

$ docker run -it --rm --runtime=runsc --network=none silex/emacs emacs: Could not open file: /dev/tty

I tried with podman as well and got the exact same results.

Steps to reproduce

$ docker run -it --rm --runtime=runsc --network=none silex/emacs emacs: Could not open file: /dev/tty

runsc version

runsc version release-20240916.0
spec: 1.1.0-rc.1

docker version (if using docker)

Client:
 Version:           20.10.24+dfsg1
 API version:       1.41
 Go version:        go1.19.8
 Git commit:        297e128
 Built:             Thu May 18 08:38:34 2023
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.24+dfsg1
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.19.8
  Git commit:       5d6db84
  Built:            Thu May 18 08:38:34 2023
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.20~ds1
  GitCommit:        1.6.20~ds1-1+b1
 runc:
  Version:          1.1.5+ds1
  GitCommit:        1.1.5+ds1-1+deb12u1
 docker-init:
  Version:          0.19.0
  GitCommit:

uname

Linux mee 6.1.0-25-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.106-3 (2024-08-26) x86_64 GNU/Linux

kubectl (if using Kubernetes)

No response

repo state (if built from source)

No response

runsc debug logs (if available)

No response

nlacasse commented 2 days ago

We just need to plumb the host.TTYFileDescription into /dev/tty device. It currently always returns EIO from open:

https://github.com/google/gvisor/blob/master/pkg/sentry/devices/ttydev/ttydev.go#L38

I hacked together #10934 , and verified that emacs runs (shudder). I need to think more about the right way to do this. That PR is not the right way.

@chetan-reddy Can you patch #10934 and check that it works for you? I only moved the cursor around and CxCc

chetan-reddy commented 2 days ago

@nlacasse I wasn't able to compile that exact PR commit, but I was able to cherry-pick your change onto an older commit on the go branch (e9d8c6f70) and can confirm that emacs now works. Thanks for the fix!

nlacasse commented 2 days ago

Awesome! I need to figure out the right way to do this, but it's good to know that this is the correct approach. I'll spend more time on this in the next week or so.