[pbs-devel] [PATCH proxmox-backup] client: mount: flush output before exiting

Gabriel Goller g.goller at proxmox.com
Fri Jun 14 11:23:42 CEST 2024


When using the `proxmox-backup-client mount` command, the parent sometimes
exits before we can print any error message. Most notably this happens
when no PBS_REPOSITORY is passed, as this is the first option checked.
Flush the stdout and stderr so that we can guarantee the output.

Reported-by: Friedrich Weber <f.weber at proxmox.com>
Suggested-by: Christian Ebner <c.ebner at proxmox.com>
Signed-off-by: Gabriel Goller <g.goller at proxmox.com>
---
 proxmox-backup-client/src/mount.rs | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/proxmox-backup-client/src/mount.rs b/proxmox-backup-client/src/mount.rs
index b69e7e80..001cbd62 100644
--- a/proxmox-backup-client/src/mount.rs
+++ b/proxmox-backup-client/src/mount.rs
@@ -1,6 +1,7 @@
 use std::collections::HashMap;
 use std::ffi::OsStr;
 use std::hash::BuildHasher;
+use std::io::{self, Write};
 use std::os::unix::io::{AsRawFd, OwnedFd};
 use std::path::{Path, PathBuf};
 use std::sync::Arc;
@@ -189,7 +190,11 @@ fn mount(
         Ok(ForkResult::Child) => {
             drop(pr);
             nix::unistd::setsid().unwrap();
-            proxmox_async::runtime::main(mount_do(param, Some(pw)))
+            let result =
+                proxmox_async::runtime::main(mount_do(param, Some(pw.try_clone().unwrap())));
+            io::stdout().flush()?;
+            io::stderr().flush()?;
+            result
         }
         Err(_) => bail!("failed to daemonize process"),
     }
-- 
2.43.0





More information about the pbs-devel mailing list