diff options
author | Karl Berry <karl@freefriends.org> | 2009-09-20 23:29:41 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-09-20 23:29:41 +0000 |
commit | 2c20e449c234f30eb26e3cbbd9cd48b281842a37 (patch) | |
tree | 60bd80b52ddd7f2e6250c5ab90e047ad455fa475 /Master/texmf-dist/scripts/perltex | |
parent | b209fd55656d0a2b7714c317d2a6656af4b1505e (diff) |
perltex 1.9 (20sep09)
git-svn-id: svn://tug.org/texlive/trunk@15387 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/perltex')
-rwxr-xr-x | Master/texmf-dist/scripts/perltex/perltex | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/Master/texmf-dist/scripts/perltex/perltex b/Master/texmf-dist/scripts/perltex/perltex index 892cf07ffc8..47f8cfc27ec 100755 --- a/Master/texmf-dist/scripts/perltex/perltex +++ b/Master/texmf-dist/scripts/perltex/perltex @@ -39,6 +39,7 @@ use Pod::Usage; use File::Basename; use Fcntl; use POSIX; +use IO::Handle; use warnings; use strict; my $latexprog; @@ -103,15 +104,41 @@ $latexcmdline[$firstcmd] = '\plmac@doneflag', $doneflag, '\plmac@pipe', $pipe, $latexcmdline[$firstcmd]; -foreach my $file ($toperl, $fromperl, $toflag, $fromflag, $doneflag, $pipe) { - unlink $file while -e $file; +$SIG{"ALRM"} = sub { + undef $latexpid; + exit 0; +}; +$SIG{"PIPE"} = "IGNORE"; +sub delete_files (@) +{ + foreach my $filename (@_) { + unlink $filename; + while (-e $filename) { + unlink $filename; + sleep 0; + } + } } +sub awaitexists ($) +{ + while (!-e $_[0]) { + sleep 0; + if (waitpid($latexpid, &WNOHANG)==-1) { + delete_files($toperl, $fromperl, $toflag, + $fromflag, $doneflag, $pipe); + undef $latexpid; + exit 0; + } + } +} +delete_files($toperl, $fromperl, $toflag, $fromflag, $doneflag, $pipe); open (LOGFILE, ">$logfile") || die "open(\"$logfile\"): $!\n"; if (defined $styfile) { open (STYFILE, ">$styfile") || die "open(\"$styfile\"): $!\n"; } if (!$usepipe || !eval {mkfifo($pipe, 0600)}) { sysopen PIPE, $pipe, O_WRONLY|O_CREAT, 0755; + autoflush PIPE 1; print PIPE $pipestring; close PIPE; $usepipe = 0; @@ -131,20 +158,7 @@ else { $sandbox_eval = \&top_level_eval; } while (1) { - my $awaitexists = sub { - while (!-e $_[0]) { - sleep 0; - if (waitpid($latexpid, &WNOHANG)==-1) { - foreach my $file ($toperl, $fromperl, $toflag, - $fromflag, $doneflag, $pipe) { - unlink $file while -e $file; - } - undef $latexpid; - exit 0; - } - } - }; - $awaitexists->($toflag); + awaitexists($toflag); my $entirefile; { local $/ = undef; @@ -229,23 +243,25 @@ while (1) { open (FROMPERL, ">$fromperl") || die "open($fromperl): $!\n"; syswrite FROMPERL, $result; close FROMPERL; - unlink $toflag while -e $toflag; - unlink $toperl while -e $toperl; - unlink $doneflag while -e $doneflag; + delete_files($toflag, $toperl, $doneflag); open (FROMFLAG, ">$fromflag") || die "open($fromflag): $!\n"; close FROMFLAG; if (open (PIPE, ">$pipe")) { + autoflush PIPE 1; print PIPE $pipestring; close PIPE; } - $awaitexists->($toperl); - unlink $fromflag while -e $fromflag; + awaitexists($toperl); + delete_files($fromflag); open (DONEFLAG, ">$doneflag") || die "open($doneflag): $!\n"; close DONEFLAG; + alarm 1; if (open (PIPE, ">$pipe")) { + autoflush PIPE 1; print PIPE $pipestring; close PIPE; } + alarm 0; } END { close LOGFILE; |