[xml/sgml-commit] [linuxdoc-tools] 09/17: LinuxDocTools.pm::process_file: Abort if pipe to nsgmls fails.
Agustín Martín Domingo
agmartin at moszumanska.debian.org
Wed May 4 17:56:08 UTC 2016
This is an automated email from the git hooks/post-receive script.
agmartin pushed a commit to branch upstream
in repository linuxdoc-tools.
commit 69733902093ad8244fb6e3048a7e530e06a95b9c
Author: Agustin Martin Domingo <agmartin at debian.org>
Date: Wed Apr 13 12:49:51 2016 +0200
LinuxDocTools.pm::process_file: Abort if pipe to nsgmls fails.
https://bugs.launchpad.net/ubuntu/+source/linuxdoc-tools/+bug/1552398
sgml processing is not stopped when pipe to nsgmls fails.
This patch uses a rather dirty hack to write exit status to a file
on nsgmls error. Existence of this file is checked and process is
properly finished if found.
Signed-off-by: Agustin Martin Domingo <agmartin at debian.org>
---
perl5lib/LinuxDocTools.pm | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/perl5lib/LinuxDocTools.pm b/perl5lib/LinuxDocTools.pm
index 2efcadd..f54d453 100644
--- a/perl5lib/LinuxDocTools.pm
+++ b/perl5lib/LinuxDocTools.pm
@@ -537,8 +537,12 @@ sub process_file {
|| die "$error_header: Could not open $global->{file} for reading. Aborting ...\n";
}
- open (my $WRITENSGMLS,
- "$precmd | $main::progs->{NSGMLS} $global->{NsgmlsOpts} $ENV{SGMLDECL} > $nsgmlsout")
+ # Pipe to nsgmls. Write exit status to $nsgmls_error_flag if not 0.
+ my $nsgmls_error_flag = "$tmpdir/nsgmls.error-flag";
+ my $nsgmls_command = "$precmd | ( $main::progs->{NSGMLS} $global->{NsgmlsOpts} $ENV{SGMLDECL} || echo \$? > $nsgmls_error_flag ) > $nsgmlsout";
+
+ unlink $nsgmls_error_flag;
+ open (my $WRITENSGMLS, "$nsgmls_command")
or die "$error_header: Could not open pipe to $nsgmlsout. Aborting ...\n";
if ($global->{charset} eq "latin") {
@@ -550,6 +554,19 @@ sub process_file {
close $IFILE;
close $WRITENSGMLS;
+ # If $nsgmls_error_flag exists an error happened. Return status and die.
+ if ( -e $nsgmls_error_flag ){
+ my $NSGMLS_STATUS;
+ open ($NSGMLS_STATUS,"< $nsgmls_error_flag")
+ or die "$error_header: Failed to open available \"$nsgmls_error_flag\" for read. Aborting ...";
+ my $nsgmls_exit_status = <$NSGMLS_STATUS>;
+ close $NSGMLS_STATUS;
+ chomp $nsgmls_exit_status;
+ unlink $nsgmls_error_flag;
+ print STDERR "$error_header: Error when piping to:\n$nsgmls_command\n" if $global->{debug};
+ die "$error_header: $main::progs->{NSGMLS} failed with exit status $nsgmls_exit_status. Aborting ...\n";
+ }
+
# Special case: if format is global, we're just checking.
cleanup if ( $global->{format} eq "global");
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-xml-sgml/linuxdoc-tools.git
More information about the debian-xml-sgml-commit
mailing list