[parted-devel] [PATCH] Don't hang when running in background with redirected stdout

Jim Meyering jim at meyering.net
Wed Feb 14 17:26:11 CET 2007


Hello,
Thanks for the nice tool!
I encountered a minor problem when using it in GNU parted
when I ran "make >& log &".  It caused the build to hang.

Here's a stand-alone demo:

Before the fix, it hangs:

  $ touch x.1; po4a-updatepo -f man -m x.1 -p x.pot >& log &
  [6] 1383
  $
  [6]  + suspended (tty output)  po4a-updatepo -f man -m x.1 -p x.pot >&log

With the following patch, it completes as you would expect:

2007-02-14  Jim Meyering  <jim at meyering.net>

	Don't hang when running in background with redirected stdout.
	* lib/Locale/Po4a/Common.pm (BEGIN): Don't try to determine output
	terminal size when STDOUT is not a terminal.

Index: lib/Locale/Po4a/Common.pm
===================================================================
RCS file: /cvsroot/po4a/po4a/lib/Locale/Po4a/Common.pm,v
retrieving revision 1.14
diff -u -p -r1.14 Common.pm
--- lib/Locale/Po4a/Common.pm	6 Dec 2005 16:32:06 -0000	1.14
+++ lib/Locale/Po4a/Common.pm	14 Feb 2007 16:11:39 -0000
@@ -1,7 +1,7 @@
 # Locale::Po4a::Common -- Common parts of the po4a scripts and utils
 # $Id: Common.pm,v 1.14 2005/12/06 16:32:06 jvprat-guest Exp $
 #
-# Copyright 2005 by Jordi Vilalta <jvprat at gmail.com>
+# Copyright 2005, 2007 by Jordi Vilalta <jvprat at gmail.com>
 #
 # This program is free software; you may redistribute it and/or modify it
 # under the terms of GPL (see COPYING).
@@ -35,7 +35,7 @@ BEGIN {
     
         # Don't bother determining the wrap column if we cannot wrap.
         my $col=$ENV{COLUMNS};
-        if (!defined $col) {
+        if (!defined $col && -t STDOUT) {
             my @term=eval "use Term::ReadKey; Term::ReadKey::GetTerminalSize()";
             $col=$term[0] if (!$@);
             # If GetTerminalSize() failed we will fallback to a safe default.



More information about the parted-devel mailing list