ls --color can't be interrupted when processing large directory

Bug #787307 reported by Nate Eldredge
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
coreutils (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Binary package hint: coreutils

When listing a large directory with --color, ls can't be interrupted with Ctrl-C or other signals.

To reproduce:

- Make a directory, /huge/dir, containing lots of files (I used about 400000 files)

- ls -l --color /huge/dir

- ls sits there for a bit while reading the directory and stat'ing all the files. Try hitting Ctrl-C. ls does not exit. Ctrl-Z, Ctrl-\ also do not work. Only SIGKILL works.

The problem appears to be that when --color is active, ls handles all signals, so that it can reset the terminal before exiting. When a signal such as SIGINT arrives, ls just sets a flag (e.g. `interrupt_signal') and at some later time calls `process_signals' to process it appropriately (by exiting). However, it seems that `process_signals' is not called while looping over the entries in a single directory; it is only called once output starts to be produced. The effect is that `ls' cannot be interrupted.

This should be easy to fix by calling `process_signals' from more places. Since it normally just tests a flag and returns, the overhead should be negligible.

This is ls from coreutils-8.5-1ubuntu6 on Ubuntu natty 11.04.

ProblemType: Bug
DistroRelease: Ubuntu 11.04
Package: coreutils 8.5-1ubuntu6
ProcVersionSignature: Ubuntu 2.6.38-8.42-generic 2.6.38.2
Uname: Linux 2.6.38-8-generic i686
Architecture: i386
Date: Mon May 23 22:31:36 2011
ProcEnviron:
 LANGUAGE=en_US:en
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: coreutils
UpgradeStatus: Upgraded to natty on 2011-04-30 (23 days ago)

Revision history for this message
Nate Eldredge (nate-thatsmathematics) wrote :
Revision history for this message
Nate Eldredge (nate-thatsmathematics) wrote :

Here is a patch that fixes it.

tags: added: patch
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in coreutils (Ubuntu):
status: New → Confirmed
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.