From 8a597efb6f239457245bdb23e04ead1d564cac79 Mon Sep 17 00:00:00 2001 From: Morten Laursen Date: Thu, 19 Oct 2023 09:14:33 +0200 Subject: [PATCH] open with O_CLOEXEC This fixes a problem with Tauri auto update: After updating the tauri application it is restarted, but the serial files were not closed, and therefore the application could not open them again. With this flag the files are closed when executing `execve()` to start the new application instance. Change-Id: I102ba33411135a8e89e3203f9dad910d385feeee --- src/posix/tty.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/posix/tty.rs b/src/posix/tty.rs index d343b8aa..06eb54ad 100644 --- a/src/posix/tty.rs +++ b/src/posix/tty.rs @@ -116,7 +116,7 @@ impl TTYPort { let path = Path::new(&builder.path); let fd = OwnedFd(nix::fcntl::open( path, - OFlag::O_RDWR | OFlag::O_NOCTTY | OFlag::O_NONBLOCK, + OFlag::O_RDWR | OFlag::O_NOCTTY | OFlag::O_NONBLOCK | OFlag::O_CLOEXEC, nix::sys::stat::Mode::empty(), )?); @@ -344,7 +344,7 @@ impl TTYPort { /// /// This function returns an error if the serial port couldn't be cloned. pub fn try_clone_native(&self) -> Result { - let fd_cloned: i32 = fcntl(self.fd, nix::fcntl::F_DUPFD(self.fd))?; + let fd_cloned: i32 = fcntl(self.fd, nix::fcntl::F_DUPFD_CLOEXEC(self.fd))?; Ok(TTYPort { fd: fd_cloned, exclusive: self.exclusive,