diff options
-rwxr-xr-x | wpdf | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -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"; |