Commit Diff


commit - fdb1653a62fcf31a8ef3467c53c2ab99fd6109c2
commit + 2d265c9244a93ab6f06672d4a8aed4a3f5dc3ff5
blob - bfede8401b8d50ecccaa607d99abfffb90a1514e
blob + 3e96945974f9e6a0b6ea5a7fd33e9b83da66df12
--- plass
+++ plass
@@ -142,25 +142,22 @@ sub passfind {
 }
 
 sub got {
-	# discard stdout
-	open my $fh, '-|', ('got', @_);
-	close($fh);
-	return !$?;
+	my $pid = fork;
+	die "failed to fork: $!" unless defined $pid;
+
+	if ($pid != 0) {
+		wait;
+		return !$?;
+	}
+
+	open (STDOUT, '>', '/dev/null')
+	    or die "can't redirect to /dev/null";
+	exec ('got', @_);
 }
 
 sub got_add {
-	my $file = shift;
-
-	open (my $null, '>', '/dev/null') or die "can't open /dev/null: $!";
-	open (my $stderr, ">&", STDERR) or die "can't save stderr: $!";
-	open (STDERR, ">&", $null) or die "can't redirect stderr: $!";
-
-	got 'info', $file;
-	my $found = !$?;
-
-	open (STDERR, ">&", $stderr) or die "can't restore stderr: $!";
-
-	return $found ? 1 : (got 'add', '-I', $file);
+	got 'add', shift
+	    or exit(1);
 }
 
 sub got_rm {