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

Christian Ebner c.ebner at proxmox.com
Fri Jun 14 11:36:49 CEST 2024


> On 14.06.2024 11:23 CEST Gabriel Goller <g.goller at proxmox.com> wrote:
> 
>  
> 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())));

Why do you clone here?

> +            io::stdout().flush()?;
> +            io::stderr().flush()?;
> +            result
>          }
>          Err(_) => bail!("failed to daemonize process"),
>      }
> -- 
> 2.43.0




More information about the pbs-devel mailing list