diff options
author | John Ankarström <john@ankarstrom.se> | 2021-06-28 16:26:49 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-06-28 16:26:49 +0200 |
commit | fbaed163427ca260d1e81ebfc8f513a90d73064d (patch) | |
tree | e420dac271fdd07a4d1b5b7774abd0e3b42bc7aa /wpdf | |
parent | 8b6d11f191a0336a47aea1f13c9af48ac17864e3 (diff) | |
download | xutil-fbaed163427ca260d1e81ebfc8f513a90d73064d.tar.gz |
wpdf: Exit when all children have exited
Diffstat (limited to 'wpdf')
-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"; |