Skip to content

Commit 9b5e2db

Browse files
hoshinolinaslp
authored andcommitted
muvm-guest: Reopen the system tty (hvc0)
This fixes the classic: -bash: cannot set terminal process group (-1): Inappropriate ioctl for device -bash: no job control in this shell I'm not entirely sure why this doesn't happen with our main shell, but it happens with things like sudo. (There are a bunch of other things needed to make sudo work, of course) Signed-off-by: Asahi Lina <[email protected]>
1 parent fddc28d commit 9b5e2db

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

crates/muvm/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env_logger = { version = "0.11.3", default-features = false, features = ["auto-c
1616
krun-sys = { path = "../krun-sys", version = "1.9.1", default-features = false, features = [] }
1717
log = { version = "0.4.21", default-features = false, features = ["kv"] }
1818
nix = { version = "0.28.0", default-features = false, features = ["user"] }
19-
rustix = { version = "0.38.34", default-features = false, features = ["fs", "mount", "process", "std", "system", "use-libc-auxv"] }
19+
rustix = { version = "0.38.34", default-features = false, features = ["fs", "mount", "process", "std", "stdio", "system", "use-libc-auxv"] }
2020
serde = { version = "1.0.203", default-features = false, features = ["derive"] }
2121
serde_json = { version = "1.0.117", default-features = false, features = ["std"] }
2222
tempfile = { version = "3.10.1", default-features = false, features = [] }

crates/muvm/src/guest/bin/muvm-guest.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::cmp;
2+
use std::os::fd::AsFd;
23
use std::os::unix::process::CommandExt as _;
34
use std::process::Command;
45

@@ -38,6 +39,17 @@ fn main() -> Result<()> {
3839
if let Err(err) = mount_filesystems() {
3940
return Err(err).context("Failed to mount filesystems, bailing out");
4041
}
42+
43+
// Use the correct TTY, which fixes pty issues etc. (/dev/console cannot be a controlling tty)
44+
let console = std::fs::OpenOptions::new()
45+
.read(true)
46+
.write(true)
47+
.create(false)
48+
.open("/dev/hvc0")?;
49+
rustix::stdio::dup2_stdin(console.as_fd())?;
50+
rustix::stdio::dup2_stdout(console.as_fd())?;
51+
rustix::stdio::dup2_stderr(console.as_fd())?;
52+
4153
Command::new("/usr/lib/systemd/systemd-udevd").spawn()?;
4254

4355
setup_fex()?;

0 commit comments

Comments
 (0)