vmm: Use cloned fd to check if dev is a tty

While checking if the console device is a tty use the cloned fd instead
of libc::STDOUT_FILENO.

Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com>
This commit is contained in:
Praveen K Paladugu 2024-06-11 15:22:37 +00:00 committed by Rob Bradford
parent c3fcddf830
commit 9f969ee18d

View File

@ -205,7 +205,7 @@ pub(crate) fn pre_create_console_devices(vmm: &mut Vmm) -> ConsoleDeviceResult<C
let stdout = unsafe { File::from_raw_fd(stdout) };
// SAFETY: FFI call. Trivially safe.
if unsafe { libc::isatty(libc::STDOUT_FILENO) } == 1 {
if unsafe { libc::isatty(stdout.as_raw_fd()) } == 1 {
vmm.console_resize_pipe = Some(
listen_for_sigwinch_on_tty(
stdout.try_clone().unwrap(),
@ -254,7 +254,7 @@ pub(crate) fn pre_create_console_devices(vmm: &mut Vmm) -> ConsoleDeviceResult<C
let stdout = unsafe { File::from_raw_fd(stdout) };
// SAFETY: FFI call. Trivially safe.
if unsafe { libc::isatty(libc::STDOUT_FILENO) } == 1 {
if unsafe { libc::isatty(stdout.as_raw_fd()) } == 1 {
vmm.console_resize_pipe = Some(
listen_for_sigwinch_on_tty(
stdout.try_clone().unwrap(),