From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>,
Dominik Csapak <d.csapak@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox] daemon: clean up middle process of double fork
Date: Mon, 2 Dec 2024 17:47:04 +0100 [thread overview]
Message-ID: <4e26505b-2348-4132-b8ac-39026d02b659@proxmox.com> (raw)
In-Reply-To: <20241129153744.4128441-1-d.csapak@proxmox.com>
Am 29.11.24 um 16:37 schrieb Dominik Csapak:
> so we don't leave around a zombie process when the old daemon still
> needs to run, because of e.g. a running task.
>
> Since this is mostly a cosmetic issue though, only try a clean up
> once, so we don't unnecessarily block or run into other issues here.
> (It could happen that it didn't exit at that point, but it's very
> unlikely.)
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> maybe the comment could be improved, but i tried to be not overly
> verbose there, since it's not really an issue anyway
>
> proxmox-daemon/src/server.rs | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/proxmox-daemon/src/server.rs b/proxmox-daemon/src/server.rs
> index efea9078..edc64795 100644
> --- a/proxmox-daemon/src/server.rs
> +++ b/proxmox-daemon/src/server.rs
> @@ -165,10 +165,12 @@ impl Reloader {
> // No matter how we managed to get here, this is the time where we bail out quickly:
> unsafe { libc::_exit(-1) }
> }
> - Ok(ForkResult::Parent { child }) => {
> + Ok(ForkResult::Parent {
> + child: middle_child,
> + }) => {
> log::debug!(
> "forked off a new server (first pid: {}), waiting for 2nd pid",
> - child
> + middle_child
> );
> std::mem::drop(pnew);
> let mut pold = std::fs::File::from(pold);
> @@ -211,6 +213,13 @@ impl Reloader {
> log::error!("child vanished during reload: {}", e);
> }
>
> + // try exactly once to get rid of the zombie process of middle_child, but
> + // non blocking and without error handling, since it's just cosmetic
> + let _ = nix::sys::wait::waitpid(
> + middle_child,
> + Some(nix::sys::wait::WaitPidFlag::WNOHANG),
> + );
why not blocking though? If that does not work something would be seriously
wrong. But not _that_ hard feelings, as long as the old process exits this
will be cleaned up by systemd anyway, but I really would like to have some
error handling here, as that definitively can only help.
> +
> Ok(())
> }
> Err(e) => {
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2024-12-02 16:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-29 15:37 Dominik Csapak
2024-12-02 9:04 ` Fabian Grünbichler
2024-12-02 16:47 ` Thomas Lamprecht [this message]
2024-12-03 9:14 ` Dominik Csapak
2024-12-03 9:29 ` Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4e26505b-2348-4132-b8ac-39026d02b659@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=d.csapak@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox