public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] client: mount: flush output before exiting
@ 2024-06-14  9:23 Gabriel Goller
  2024-06-14  9:36 ` Christian Ebner
  0 siblings, 1 reply; 3+ messages in thread
From: Gabriel Goller @ 2024-06-14  9:23 UTC (permalink / raw)
  To: pbs-devel

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@proxmox.com>
Suggested-by: Christian Ebner <c.ebner@proxmox.com>
Signed-off-by: Gabriel Goller <g.goller@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



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup] client: mount: flush output before exiting
  2024-06-14  9:23 [pbs-devel] [PATCH proxmox-backup] client: mount: flush output before exiting Gabriel Goller
@ 2024-06-14  9:36 ` Christian Ebner
  2024-06-14  9:40   ` Gabriel Goller
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Ebner @ 2024-06-14  9:36 UTC (permalink / raw)
  To: Gabriel Goller, pbs-devel


> On 14.06.2024 11:23 CEST Gabriel Goller <g.goller@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@proxmox.com>
> Suggested-by: Christian Ebner <c.ebner@proxmox.com>
> Signed-off-by: Gabriel Goller <g.goller@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


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pbs-devel] [PATCH proxmox-backup] client: mount: flush output before exiting
  2024-06-14  9:36 ` Christian Ebner
@ 2024-06-14  9:40   ` Gabriel Goller
  0 siblings, 0 replies; 3+ messages in thread
From: Gabriel Goller @ 2024-06-14  9:40 UTC (permalink / raw)
  To: Christian Ebner; +Cc: pbs-devel

On 14.06.2024 11:36, Christian Ebner wrote:
>> 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?

Oops, my bad. Forgot to remove this.


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-14  9:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-14  9:23 [pbs-devel] [PATCH proxmox-backup] client: mount: flush output before exiting Gabriel Goller
2024-06-14  9:36 ` Christian Ebner
2024-06-14  9:40   ` Gabriel Goller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal