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

Gabriel Goller g.goller at proxmox.com
Fri Jun 14 11:39:39 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>
---

v2, thanks @Christian:
 - Removed unneeded pw.try_clone()

 proxmox-backup-client/src/mount.rs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/proxmox-backup-client/src/mount.rs b/proxmox-backup-client/src/mount.rs
index b69e7e80..e7718b84 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,10 @@ 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)));
+            io::stdout().flush()?;
+            io::stderr().flush()?;
+            result
         }
         Err(_) => bail!("failed to daemonize process"),
     }
-- 
2.43.0





More information about the pbs-devel mailing list