return $nodehash
}
-sub check_cmdline {
- my ($pidfile, $pid) = @_;
+sub parse_cmdline {
+ my ($pid) = @_;
my $fh = IO::File->new("/proc/$pid/cmdline", "r");
if (defined($fh)) {
my $cmd = $param[0];
return if !$cmd || ($cmd !~ m|kvm$| && $cmd !~ m@(?:^|/)qemu-system-[^/]+$@);
+ my $phash = {};
+ my $pending_cmd;
for (my $i = 0; $i < scalar (@param); $i++) {
my $p = $param[$i];
next if !$p;
- if (($p eq '-pidfile') || ($p eq '--pidfile')) {
- my $p = $param[$i+1];
- return 1 if $p && ($p eq $pidfile);
- return undef;
+
+ if ($p =~ m/^--?(.*)$/) {
+ if ($pending_cmd) {
+ $phash->{$pending_cmd} = {};
+ }
+ $pending_cmd = $1;
+ } elsif ($pending_cmd) {
+ $phash->{$pending_cmd} = { value => $p };
+ $pending_cmd = undef;
}
}
+
+ return $phash;
}
return undef;
}
if ($line =~ m/^(\d+)$/) {
my $pid = $1;
- if (check_cmdline($pidfile, $pid)) {
+ my $cmdline = parse_cmdline($pid);
+ if ($cmdline && defined($cmdline->{pidfile}) && $cmdline->{pidfile}->{value}
+ && $cmdline->{pidfile}->{value} eq $pidfile) {
if (my $pinfo = PVE::ProcFSTools::check_process_running($pid)) {
return $pid;
}