aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xwpdf13
1 files changed, 11 insertions, 2 deletions
diff --git a/wpdf b/wpdf
index 99fa525..5700bc4 100755
--- a/wpdf
+++ b/wpdf
@@ -5,7 +5,11 @@
use strict;
use warnings;
-my %deptarget; # dependency => target
+my $alive; # number of children alive
+my %deptarget; # dependency => target
+my $parent = $$; # pid of parent
+
+$SIG{HUP} = sub { kill 'INT', $parent if not --$alive };
# collect dependencies for given pdf files
for my $target (@ARGV) {
@@ -27,7 +31,12 @@ for my $target (@ARGV) {
}
}
close $f;
- exec('xpdf', '-remote', "wpdf-$target", $target) if fork == 0;
+ if (fork == 0) {
+ system 'xpdf', '-remote', "wpdf-$target", $target;
+ kill 'HUP', $parent;
+ exit;
+ }
+ $alive++;
next;
} else {
warn "skipping $_: not a pdf\n";