factor buffers output when run interactively

Bug #1620139 reported by Neil Turton
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
coreutils
Fix Released
Undecided
Unassigned
coreutils (Ubuntu)
New
Undecided
Unassigned

Bug Description

When the "factor" utility is run without any arguments, it reads numbers from stdin and writes the factors to stdout. One use case for this mode is to run factor in a terminal window and enter numbers manually. This worked well in coreutils 8.23 and earlier. However, in coreutils 8.25, the output of factor is buffered, making this mode of operation less useful.

Notice that in the logs for version 8.25, all of the output occurs after end-of-file has been reached on stdin.

I entered the following input:
  factor --version
  factor
  5
  7
  9
  ^D

bash$ factor --version
factor (GNU coreutils) 8.23
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Paul Rubin, Torbjörn Granlund, and Niels Möller.
bash$ factor
5
5: 5
7
7: 7
9
9: 3 3
bash$

bash$ factor --version
factor (GNU coreutils) 8.25
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Paul Rubin, Torbjörn Granlund and Niels Möller.
bash$ factor
5
7
9
5: 5
7: 7
9: 3 3
bash$

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: coreutils 8.25-2ubuntu2
ProcVersionSignature: Ubuntu 4.4.0-36.55-generic 4.4.16
Uname: Linux 4.4.0-36-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.1
Architecture: amd64
CurrentDesktop: KDE
Date: Sun Sep 4 23:32:33 2016
EcryptfsInUse: Yes
InstallationDate: Installed on 2013-08-13 (1118 days ago)
InstallationMedia: Ubuntu 12.04.2 LTS "Precise Pangolin" - Release amd64 (20130213)
SourcePackage: coreutils
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Neil Turton (0neiltk-launchpad) wrote :
Revision history for this message
Pádraig Brady (p-draigbrady) wrote :

Yes that operation was changed in 8.25 to ensure atomic output,
thus allowing one to run multiple factor processes in parallel
and collate the output.

I'll look at disabling this internal buffering if the output is line buffered
(which it will be if outputting to a terminal, or if stdbuf -oL is used)

Revision history for this message
Neil Turton (0neiltk-launchpad) wrote :

That seems like a good approach. Thanks for looking at this.

Revision history for this message
Pádraig Brady (p-draigbrady) wrote :
Revision history for this message
C de-Avillez (hggdh2) wrote :

this fix will need an SRU for 16.04.

Changed in coreutils:
status: New → Fix Released
Changed in coreutils (Ubuntu):
milestone: none → xenial-updates
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.