[pve-devel] [PATCH common 2/3] INotify.pm: use run_command instead of open for calling diff

Dominik Csapak d.csapak at proxmox.com
Fri Aug 24 12:34:08 CEST 2018


Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/PVE/INotify.pm | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index 50a1a76..cadd78f 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -19,7 +19,8 @@ use PVE::ProcFSTools;
 use Clone qw(clone);
 use Linux::Inotify2;
 use base 'Exporter';
-use JSON; 
+use JSON;
+use Encode qw(encode decode);
 
 our @EXPORT_OK = qw(read_file write_file register_file);
 
@@ -56,13 +57,11 @@ sub ccache_compute_diff {
 
     my $diff = '';
 
-    open (TMP, "diff -b -N -u '$filename' '$shadow'|");
-	
-    while (my $line = <TMP>) {
-	$diff .= $line;
-    }
-
-    close (TMP);
+    my $cmd = ['/usr/bin/diff', '-b', '-N', '-u', $filename, $shadow];
+    PVE::Tools::run_command($cmd, noerr => 1, outfunc => sub {
+	my ($line) = @_;
+	$diff .= decode('UTF-8', $line) . "\n";
+    });
 
     $diff = undef if !$diff;
 
-- 
2.11.0





More information about the pve-devel mailing list