From: "Shannon Sterz" <s.sterz@proxmox.com>
To: "Jordyn Hamilton" <j.hamilton@proxmox.com>,
<pve-devel@lists.proxmox.com>
Cc: c.hughes@proxmox.com
Subject: Re: [PATCH common 1/2] Added subroutine to check process status
Date: Thu, 19 Nov 2026 16:33:48 +0100 [thread overview]
Message-ID: <DMZAPB53479Z.3GBF4WDSUDINH@proxmox.com> (raw)
In-Reply-To: <20261119145011.8017-2-j.hamilton@proxmox.com>
On Thu Nov 19, 2026 at 3:50 PM CET, Jordyn Hamilton wrote:
> Added a subroutine to check if a process is in a D state. It does so by
> reading the processes `stat` file from `/proc/$pid/stat`, then using
> regex to grab a group containing the status character. It then returns
> true or false if the status is 'D'. Not checking for any other status
> types as D state is the only one that needs special logic.
>
> Signed-off-by: Jordyn Hamilton <j.hamilton@proxmox.com>
> ---
> src/PVE/Cmd.pm | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/src/PVE/Cmd.pm b/src/PVE/Cmd.pm
> index 65d00a7..773e55a 100644
> --- a/src/PVE/Cmd.pm
> +++ b/src/PVE/Cmd.pm
> @@ -44,6 +44,18 @@ sub split_args($str) {
> return $str ? [Text::ParseWords::shellwords($str)] : [];
> }
>
> +# check a subprocesses `/proc/<PID>/stat` file for a D state
> +sub in_d_state($pid) {
> + open my $pstat_h, '<', "/proc/$pid/stat" or die $!;
> + my $stat_in = <$pstat_h>;
> + close $pstat_h;
nit: our style guide prefers the use of parentheses for function calls
[1].
[1]: https://pve.proxmox.com/wiki/Perl_Style_Guide#Perl_syntax_choices
> +
> + # extracting the stat character from the input
> + my $status = $1 if $stat_in =~ /^\d+\s+\(.*\)\s+([A-Z])/;
> +
> + return ($status eq 'D');
> +}
> +
> # The $cmd parameter can be:
> # -) a string
> # This is generally executed by passing it to the shell with the -c option.
next prev parent reply other threads:[~2026-11-19 15:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 14:50 [PATCH common 0/2] Adding D state checking to the run command Jordyn Hamilton
2026-11-19 14:50 ` [PATCH common 1/2] Added subroutine to check process status Jordyn Hamilton
2026-11-19 15:33 ` Shannon Sterz [this message]
2026-11-19 14:50 ` [PATCH common 2/2] Added logic to check for d state to run subroutine Jordyn Hamilton
2026-11-19 15:33 ` Shannon Sterz
2026-11-19 15:33 ` [PATCH common 0/2] Adding D state checking to the run command Shannon Sterz
2026-11-19 18:49 ` superseded " Jordyn Hamilton
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=DMZAPB53479Z.3GBF4WDSUDINH@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=c.hughes@proxmox.com \
--cc=j.hamilton@proxmox.com \
--cc=pve-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