]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/ProcFSTools.pm
add missing check for undef in is_mounted
[pve-common.git] / src / PVE / ProcFSTools.pm
index 99f767a172b7e1f0bc687d44c043a8123fd0d347..eadb4e6cda52abf1dc83a7432d33aaad00cffa00 100644 (file)
@@ -323,6 +323,8 @@ sub is_mounted {
 
     $mountpoint = Cwd::realpath($mountpoint);
 
+    return 0 if !defined($mountpoint); # path does not exist
+
     my $mounts = parse_proc_mounts();
     return (grep { $_->[1] eq $mountpoint } @$mounts) ? 1 : 0;
 }
@@ -352,4 +354,24 @@ sub read_proc_net_ipv6_route {
     return $res;
 }
 
+sub upid_wait {
+    my ($upid, $waitfunc, $sleep_intervall) = @_;
+
+    my $task = PVE::Tools::upid_decode($upid);
+
+    $sleep_intervall = $sleep_intervall ? $sleep_intervall : 1;
+
+    my $next_time = time + $sleep_intervall;
+
+    while (check_process_running($task->{pid}, $task->{pstart})) {
+
+       if (time >= $next_time && $waitfunc && ref($waitfunc) eq 'CODE'){
+           &$waitfunc($task);
+           $next_time = time + $sleep_intervall;
+       }
+
+       CORE::sleep(1);
+    }
+}
+
 1;